Push Mercurial subrepo to the same path as its parent

144 Views Asked by At

Is there any way to configure Mercurial to push a subrepository to the same path specified when pushing its parent?

Say we have a parent repo with a subrepo, and the subrepo also has its own subrepo:

A
- B
- - C

Now, in each of A, B, and C we have alternate paths specified:

A .hg/hgrc

[paths]
default = http://path.to.default/A
devMachine = ssh://[email protected]/A

B .hg/hgrc

[paths]
default = http://path.to.default/B
devMachine = ssh://[email protected]/A/B

C .hg/hgrc

[paths]
default = http://path.to.default/C
devMachine = ssh://[email protected]/A/B/C

If I have unpublished changesets in A, B, and C, that I do not want to push to the central repository, but I DO want to push them between my Work & Home dev machines, is there any way I can set up Mercurial such that when I do hg push devMachine it will push B and C to devMachine as well, rather than pushing A to devMachine and pushing both B and C to default?

What I have been doing thus far is setting the new-commit phase to secret and doing:

$ cd A/B/C
A/B/C$ hg phase -d
A/B/C$ hg push devMachine
A/B/C$ hg phase -sf
A/B/C$ cd ..
A/B$ hg phase -d
A/B$ hg push devMachine
A/B$ hg phase -sf
A/B$ cd ..
A$ hg phase -d
A$ hg push devMachine
A$ hg phase -sf

For obvious reasons this is less than optimal. It would be much nicer if doing A$ hg push devMachine would recursively push all subrepos to the devMachine path (given that it has been defined in .hg/hgrc of course).

I know I could script this pretty easily. I'm just curious if Mercurial has something built-in that will do this that I haven't been able to find.

1

There are 1 best solutions below

3
Marcos Zolnowski On

I DO want to push them between my Work & Home dev machines, is there any way I can set up Mercurial such that when I do hg push devMachine it will push B and C to devMachine as well, rather than pushing A to devMachine and pushing both B and C to default?

Well, it works this way using TortoiseHg. The hgrc path section was set the same way you described. But the path alias was not being used in the call.

Log output was: hg push some-real-absolute-path

Instead of hg push devMachine, try hg push ssh://[email protected]/A

About the phases, in every repository of the Work(and/or Home) machine, add to hgrc:

[phases]
publish = False

Then commits will change to public phase, only when pushing to the central repository.

I advise to NOT use:

[phases]
new-commit = secret

Secret phase doesn't mix that well in subrepositories. I would only use it in the root repository.