Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top