How to preserve Mercurial subrepo remappings across clone/pull?

451 Views Asked by At

I'm trying to set up subrepo remapping in Mercurial (2.1.1) to account for subrepo paths that may change in the future. I've been able to get the [subpaths] key to be read and processed properly when it is specified in the .hgrc file. However, when I clone or pull from that repository, the .hgrc file is not copied and thus the subrepo remaps are not brought over to the destination repository.

My first thought after looking at the SubrepoRemappingPlan was to put the [subpaths] in a .hg/subpaths file, which is supposed to be copied on clones/pulls. However, it turns out this functionality has been obsoleted, and the subpaths file has been replaced with a more general configuration-sharing mechanism via the Projrc extension.

The problems with the Projrc solution, though, are:

  1. it's a separate extension that all team members need to have installed and enabled

  2. additional configuration needs to be done to tell Projrc where it is allowed to pull from (and what it is allowed to pull), for security reasons

So, my question is, is there any built-in mechanism in Mercurial for implementing subrepo mapping that is preserved across clones/pulls?

2

There are 2 best solutions below

0
On

Adding the subpaths mapping to your .hgsub file should do the trick (as described in the mercurial wiki).

4
On

Generally, the best method is to use relative paths for subrepos (see http://mercurial.aragost.com/kick-start/en/subrepositories/) so they never have to be remapped at all.

Example:

+ main repo
  + subrepo
  + .hgsub

.hgsub:

subrepo = subrepo