2

The mercurial documentation recommends to use trivial relative paths in .hgsub and use [subpaths] to map to the absolute paths. I don't fully understand the reasoning behind this. The argument on the documentation page is that absolute paths are more likely to change. Wouldn't the solution with [subpaths] require a change, too, whenever the absolute path changes?

One reason I can understand (but it doesn't apply in my case) is that clones of clones are only possible using [subpaths] to remap full original paths to the absolute path. If absolute paths would be used directly, the clone of the clone would push/pull from the original and not the first clone. Is this the only reason against using absolute paths without a [subpaths] section?

Flogo
  • 1,673
  • 4
  • 20
  • 33

1 Answers1

2

The primary reason is because sometimes paths change and your .hgsub is part of history. If your subrepo moves from http://tinyco.com/hg/repo1 to http://bigco.com/tinydivision/hg/repo1 you can update your .hgsub file of course, but the old version in place for past revisions. Thus when you do hg update reallly_old_revision it'll try to talk to http:/tinyco.com, which got nerfed as part of the acquisition. If you keep a trivial path as the subrepo path then you can use [subpaths] in your .hg/hgrc to point it to where it currently lives.

It's also, often handy, to point subrepos toward your own local clones of the real subrepo, so that you can push to it even if you're unable to push to the subrepo (no permission).

In general adding a layer of indirection adds flexibility.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • Thanks, I didn't realize that I could also have a `[subpaths]` section in my `.hg/hgrc`. If the only `[subpaths]` section is in the file `.hgsub` than that would be incorrect in an old revision, as well. Will the entries in `.hg/hgrc` overwrite entries in `.hgsub`, i.e. can I have my default settings in `.hgsub` and update `.hg/hgrc` when paths change? – Flogo Feb 04 '14 at 09:11
  • Yes, that's my understanding. – Ry4an Brase Feb 04 '14 at 18:41