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

一世执手 提交于 2019-12-07 07:39:57

问题


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?


回答1:


In your .hgsub file you could use the http://[user[:pass]@]host[:port]/[path][#revision] (or local/filesystem/path[#revision]) syntax (see hg help urls for more examples) to anchor the subrepo to a specific revision. For that revision string you could even use #branchname or #tagname so that you track the tip of a specific branch (ex stable) or a moveable tag (ex: release) so that you only get the new version when a branch or tag on the remote subrepo are updated.




回答2:


(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.




回答3:


It does seem that Mercurial subrepos are always updated to the latest tip of the remote repository.

I propose that, if you are using a particular version of a remote repository and updating that version only infrequently, it's better to fold that revision into your main repository. This means you are no longer dependent on the external source for a checkout.



来源:https://stackoverflow.com/questions/3190386/is-it-possible-to-peg-a-mercurial-subrepo-to-a-specific-revision-like-svnexter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!