首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么单独的Mercurial分支中的标记不起作用?

为什么单独的Mercurial分支中的标记不起作用?
EN

Stack Overflow用户
提问于 2012-10-09 20:13:32
回答 1查看 611关注 0票数 2

我正在设置一个Mercurial存储库来跟踪第三方代码,大致遵循Rudi对this question的回答中描述的供应商默认分支方案。为了快速检索特定版本,我为每个供应商和默认版本创建了标签。

我通过提交一个空的.hgtags来建立默认分支来初始化存储库,然后我hg branch vendor并导入第一个版本。添加新版本的过程如下所示:

代码语言:javascript
复制
hg up -C vendor
... load new version ...
hg commit -A -m "Adding version x.y.x"
hg tag vendor-x.y.z
hg up -C default
hg merge vendor
hg commit -m "Merging version x.y.z"
hg tag x.y.z

在合并期间,我始终保留.hgtags的本地副本,因此结果是供应商分支具有包含所有供应商- x.y.z标记的.hgtags,而默认分支.hgtags仅具有x.y.z标记。

我的理解是,Mercurial在使用标签时会从各个方面考虑.hgtags。然而,当我运行hg tags时,结果只包含tip和x.y.z标记。无论我的工作目录更新到哪个分支,这都是相同的;它始终是来自默认分支.hgtags文件的标记。

我可以更新供应商-x.y.z标记,这样Mercurial确实可以看到它们的存在,但更新似乎给出了供应商分支提示中的代码。x.y.z标记工作正常。

我过去主要使用Git和SVN/CVS,所以我认为这是一个理解问题,而不是技术问题。为了以防万一,我确实在Mercurial的两个版本(2.0.2和2.3.2)上进行了尝试,并获得了相同的结果。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-09 20:33:47

我不是在我的Mercurial系统前验证,但我认为问题是Mercurial只从拓扑头考虑.hgtags,而不是分支头。示例:

代码语言:javascript
复制
[1]---[2]---[5]---[6]    Default
        \         /
         [3]---[4]       Vendor

6是拓扑头,4和6是分支头。解决方案是在合并时保留对.hgtags的所有更改。

编辑

这是我的测试。合并之后,我直接接受了本地.hgtags,而hg tags只在default上显示标记。我无法更新供应商标签,它与您看到的不同。我使用的是Mercurial 2.3.1。在供应商上创建另一个变更集并创建第二个拓扑头之后,丢失的标记会重新出现。

代码语言:javascript
复制
hg init test
cd test
echo >a
hg ci -Am 1
hg branch vendor
echo >b
hg ci -Am 2
hg tag v1
hg update default
hg tag d1
hg merge vendor --tool internal:local
hg ci -m Merge

@REM This only shows 'tip' and 'd1'
hg tags

hg update vendor
hg tags
hg update d1

@REM This fails to update.
hg update v1

@ Add another topological head by committing to vendor
hg update vendor
echo >c
hg ci -Am 3

@ Now all tags are visible and work.
hg tags
hg update v1
hg update d1

和输出:

代码语言:javascript
复制
C:\>hg init test
C:\>cd test
C:\test>echo  1>a
C:\test>hg ci -Am 1
adding a
C:\test>hg branch vendor
marked working directory as branch vendor
(branches are permanent and global, did you want a bookmark?)
C:\test>echo  1>b
C:\test>hg ci -Am 2
adding b
C:\test>hg tag v1
C:\test>hg update default
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
C:\test>hg tag d1
C:\test>hg merge vendor --tool internal:local
1 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
C:\test>hg ci -m Merge
C:\test>hg tags
tip                                4:80759c41b3cc
d1                                 0:17b05ed457d1
C:\test>hg update vendor
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
C:\test>hg tags
tip                                4:80759c41b3cc
d1                                 0:17b05ed457d1
C:\test>hg update d1
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
C:\test>hg update v1
abort: unknown revision 'v1'!
C:\test>hg update vendor
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
C:\test>echo  1>c
C:\test>hg ci -Am 3
adding c
C:\test>hg tags
tip                                5:a2c0fe73a9f1
v1                                 1:3168d0f4e5e5
d1                                 0:17b05ed457d1
C:\test>hg update v1
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
C:\test>hg update d1
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12799801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档