Mercurial [subpaths] containing absolute path is appended to main repo's default path when pushing

412 views Asked by At

Running Mercurial 2.0.2 on Windows:

In my .hgrc:

[subpaths]
MYREPOS/(.*) = https://server/repos/\1

And in my .hgsub:

subrepo/lib = MYREPOS/lib

When I do a push, the push path of the sub repo is the concatenation of it's path to the main repo, rather than an absolute path - the output is:

pushing to https://server/repos/main 
pushing subrepo subrepo\lib to https://server/repos/main/http%3A//server/repos/lib

I would have expected:

pushing to https://server/repos/main
pushing subrepo subrepo\lib to https://server/repos/lib

Is it because the 'absoluteness or relativeness' of the sub repo path is determined by right hand path in .hgsub and not the value it is mapped to? For example, MYREPOS/lib is relative, and therefore the mapped path will be treated as relative, whether it is or not?

1

There are 1 answers

0
Martin Geisler On BEST ANSWER

The subrepository logic was changed between 1.9 and 2.0. The procedure is now:

  1. if the path in .hgsub is relative, then join it with the main repository path
  2. apply remapping rules to this final path

Before this change, we would:

  1. apply remapping rules to the path from .hgsub
  2. if the remapped path is relative, then join it with the main repository path

So you're right that MYREPOS/lib is seen as a relative path in the first step. The full path for the subrepository is therefore

https://server/repos/main/MYREPOS/lib

and your remapping pattern still triggers. This explains why you see http://... in the middle of the push URL. However, there is a fallback that will revert to the old behavior. If your pattern is

^MYREPOS/(.*) = https://server/repos/\1

then it wont match anything in the new step 2 — it will only remap MYREPOS at the beginning of the path. We notice this and use the old algorithm!