[PATCH 1 of 1] Add create option to push command

Thomas Arendsen Hein thomas at intevation.de
Thu Mar 1 21:04:38 UTC 2007


* Shane Holloway <shane.holloway at ieee.org> [20070301 18:14]:
> On Feb 28, 2007, at 2:21 PM, Thomas Arendsen Hein wrote:
> >* Shane Holloway <shane.holloway at ieee.org> [20070228 18:31]:
> >>We create a lot of branches in our use of mercurial, with heavy
> >>use of the hgrc paths options.  To make our lives easier, we
> >>desired a --create option for the push command so we could skip
> >>the hg init for non-existent remote repos, as well as use the hgrc
> >>paths.  If we wanted this feature, I figure others would as well.
> >
> >hg clone . <target>
> 
> That's true, but it does not use the [paths] from the local hgrc, AFAICT

Currently all commands prefer local accessible paths over [paths],
e.g. if you have a [paths] entry "foo" and a directory "foo", then
hg log -R "foo" accesses the directory.

hg init <target> and hg clone . <target> can't see an existing
directory because they create it on their own. Allowing [paths]
here, might be surprising, because you write to a location (possibly
on a different host!) that previously didn't exist.

> >should already do this.
> >
> >And what is the use case of using [paths]?
> 
> When creating a new remote target, I edit the local hgrc file for the repo, adding a nice short name, and then 
> simply hg push to it.  As it stands without this patch, I have to::
> 
> 	hg init ssh://scc.company.com:7272/hg/share/shane/project/myrepo
> 	vim `hg root`/.hg/hgrc
> 		<add ssh://scc.company.com:7272/hg/share/shane/project/myrepo  to [paths] section>
> 	hg push myrepo
> 
> Essentially typing in the repo path twice, introducing the opportunity for error.  In our environment, we have a 
> directory hierarchy setup to support multiple users as well as multiple official project releases, each which get a 
> repository snapshot.  Hence pushing our repos to new repos has become a common operation.  With hg clone, the 
> operation is not a whole lot different::
> 
> 	hg clone -U ssh://scc.company.com:7272/hg/share/shane/project/myrepo
> 	vim `hg root`/.hg/hgrc
> 		<add ssh://scc.company.com:7272/hg/share/shane/project/myrepo  to [paths] section>
> 
> Still having the duplication of the repo string.  But with the hg push -c addition, only one addition is needed, and 
> from the context of an editor and existing [paths] entries::
> 
> 	vim `hg root`/.hg/hgrc
> 		<add ssh://scc.company.com:7272/hg/share/shane/project/myrepo  to [paths] section>
> 	hg push -c myrepo
> 
> 
> I did not think it would be appropriate for hg clone to add an entry to the hgrc for the path with an option, but 
> that could be pursued.

An existing .hg/hgrc should never be modified my Mercurial, only by
the user. So clone to a different repo should only edit the target's
hgrc if this is in the local filesystem.

But for your use case:
As soon as you push your repo to an ssh location, does this become
the canonical location for it? If yes, you probably always want to
change .hg/hgrc [paths] default to this location.

A small shell script (or even a small hg python extension to have it
easily available as a new subcommand) could do this for you in the
way _you_ want. Even if it shouldn't be named 'default, supporting
options in own commands is easy to implement.

BTW, you don't need -U for remote clones, because it only does init
and push, no checkout is created.

Thomas

-- 
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrück - Registereintrag: Amtsgericht Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner



More information about the Mercurial mailing list