mercurialexternalssubrepos

Is it possible to peg a Mercurial subrepo to a specific revision (like svn:externals)?


I'm migrating a set of projects from Subversion to Mercurial. The projects currently use svn:externals to pull code from one into the others. I've been following the recommendation to point externals to a specific revision number and manually update it as needed (so that when I update to a past revision of the main project, I get the past version of the externals too).

The way to do externals in Mercurial seems to be with subrepos, but I don't see a way to peg them to a specific revision - it looks like Hg will always update the subrepos to the latest revision whenever I update the main repo. Is that correct? And is there a way to work around it?


Solution

  • (copied from my comment above)

    Turns out I was wrong. It doesn't update to the latest revision, it updates to the revision specified in the .hgsubstate file, which is version controlled and automatically updated at each commit. So this is actually easier than SVN externals since the revision doesn't have to be manually re-pegged; each revision of the main repo is automatically associated with the corresponding revisions of the subrepos.