1

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://user@dev.machine/A

B .hg/hgrc

[paths]
default = http://path.to.default/B
devMachine = ssh://user@dev.machine/A/B

C .hg/hgrc

[paths]
default = http://path.to.default/C
devMachine = ssh://user@dev.machine/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.

Jordan
  • 4,133
  • 1
  • 27
  • 43

1 Answers1

0

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://user@dev.machine/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.

Marcos Zolnowski
  • 2,751
  • 1
  • 24
  • 29
  • No, this is not how it works in TortoisHG (at least not v 4.6.1 for macOS). I just tried it. When I push, it will push A to 'ssh://user@dev.machine/A', as expected, then it does 'pushing subrepo B to http://path.to.default/B'. A mercurial `[path]` is just an alias, so I don't see any reason why explicitly using a path would make a difference anyways. – Jordan Aug 24 '18 at 15:28
  • This works for TortoiseHg 4.6.2 on Linux. I made some repositories just to test this, and they work fine here. – Marcos Zolnowski Aug 24 '18 at 21:55
  • Huh, sounds like there's a discrepancy between macOS & Linux in the implementation. Too bad for me. – Jordan Aug 27 '18 at 17:46