Search code examples
mercurialmercurial-subrepos

Multiple paths for subrepositories


I have main repository and 12 subrepositories in it. .hgsub contains mappings of local paths and repository hosting URLs. Besides default pull/push URLs for subrepositories, I need to be able to push each subrepository to another server as a standalone repository. So, I add new path alias in .hg/hgrc of each subrepository.

The problem is that aliases are not save anywhere except my local machine, so when I do clean clone of main repository, this aliases are gone and I need to setup them again.

Can I permanently save this path aliases in repository configuration file or maybe there's some workaround for this?


Solution

  • I think the best option available to you is to keep a .hgrc snippet in place in the parent repository filled with [subpaths] entries. For example create subpaths.hgrc as a tracked file in your repository:

    [subpaths]
    repoa = http://remote/path/to/repo/a
    repob = http://remote/path/to/repo/b
    

    Then when you want to initialize those repositories you add this line to your clone's .hg/hgrc:

    %include ../subpaths.hgrc
    

    and then comment it out when you want the repoa and repob paths being their usual, local selves.