是否可以将 Mercurial 子存储库与特定修订版挂钩(例如 svn:externals)?
我正在将一组项目从 Subversion 迁移到 Mercurial。这些项目当前使用 svn:externals 将代码从一个项目拉取到另一个项目中。我一直遵循建议将外部指向特定修订号并根据需要手动更新它(这样当我更新到主项目的过去版本时,我也可以获得外部的过去版本)。
在 Mercurial 中执行外部操作的方法似乎是使用子存储库,但我没有找到将它们与特定版本挂钩的方法 - 看起来每当我更新主存储库时,Hg 都会将子存储库更新到最新版本。这是正确的吗?有没有办法解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在您的 .hgsub 文件中,您可以使用 http://[user[:pass]@]host[:port]/[path][#revision] (或
local/filesystem/path[#revision]
) 语法(请参阅hg help urls
了解更多示例)将子存储库锚定到特定修订版。对于该修订字符串,您甚至可以使用#branchname
或#tagname
以便跟踪特定分支(例如stable
)或可移动标签(例如:release
),以便您仅在远程子存储库上的分支或标签更新时获得新版本。In your
.hgsub
file you could use thehttp://[user[:pass]@]host[:port]/[path][#revision]
(orlocal/filesystem/path[#revision]
) syntax (seehg 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 (exstable
) 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.(从我上面的评论复制)
事实证明我错了。它不会更新到最新版本,而是更新到 .hgsubstate 文件中指定的版本,该文件受版本控制并在每次提交时自动更新。因此,这实际上比 SVN 外部更容易,因为修订版不必手动重新挂钩;主存储库的每个修订版都会自动与子存储库的相应修订版相关联。
(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.
Mercurial 子存储库似乎总是更新到远程存储库的最新提示。
我建议,如果您使用远程存储库的特定版本并且很少更新该版本,那么最好将该修订版本折叠到您的主存储库中。这意味着您不再依赖外部来源进行结账。
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.