Mercurial:如果标签具有相同名称,如何切换到命名分支?
我现在只是在玩 Mercurial,这可能永远不会成为问题,但我刚刚创建了一个存储库并添加了一些更改。我在某一点标记了它,然后在另一点创建了一个命名分支。标签和分支具有相同的名称。如果我执行 hg update name
,它会切换到标记版本。除了使用分支上的修订号之外,还有其他方法可以切换到分支吗?
我认为让我想到这一点的是,如果我们要编写一些脚本来自动构建特定修订版,我们只想指定一个标签或一个分支来构建。如果有人碰巧在标签和分支中使用相同的名称,那么我们在脚本获取正确修订版时就会遇到问题。唯一的解决方案是确保它们是唯一的,例如通过在名称前添加分支或标签?
I am just playing around with Mercurial at the moment and this may never come up as an issue, but I just created a repository and added some changes. I tagged it at one point then created a named branch at another. Both the tag and the branch have the same name. If I do hg update name
it switches to the tagged version. Is there any way to switch to the branch other than by using a revision number on the branch?
I think what made me think about this was that if we were to write some scripts for automatically building a particular revision we would want to just specify either a tag or a branch to build from. If someone happened to use the same name in a tag and a branch then we would run into problems with the script getting the correct revisions. Is the only solution to this to make sure that they are unique, e.g. by pre-pending branch or tag to the name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过解析
hg Branches
的输出来获取分支的最新版本。考虑这种情况(一个分支和一个标签,都名为
popular
):在类似 bash 的 shell 中,您会得到 branch
popular
的尖端版本with:获取标签版本的工作方式类似,使用
hg标签
。现在您的脚本可以更新到有问题的分支/标签。
You get the tip revision of the branch by parsing the output of
hg branches
.Consider this situation (a branch and a tag, both named
popular
):In bash-like shells, you get the tip revision of branch
popular
with:Getting the tag revision works similar, using
hg tags
.Now your script is able to update to the branch/tag in question.
我认为你可以这样做:
它使用 revsets 功能(请参阅较新的 Mercurial 中的
hg help revsets
)。但如果是我的话,我会在殴打创建标签的人的头部和颈部后删除标签。
I think you could do it with:
which uses the revsets feature (see
hg help revsets
in a newer Mercurial).But were it me I'd just delete the tag after beating the person who created it about the head and neck.