Mercurial,“带有书签的分支"; [英] Mercurial, "Branching with bookmarks"
问题描述
我阅读了这份文档:分支指南Mercurial ,特别是标题为使用书签进行分支.
I read this document: A Guide to Branching with Mercurial, specifically the section titled Branching with Bookmarks.
它说:
现在,在当前变更集中,您的两个分支有两个书签(基本上是一个标签).
Now you’ve got two bookmarks (essentially a tag) for your two branches at the current changeset.
要切换到这些分支之一,可以使用hg update feature
更新到该分支的技巧变更集,并将自己标记为在该分支上工作.提交后,它将书签移动到新创建的变更集.
To switch to one of these branches you can use hg update feature
to update to the tip changeset of that branch and mark yourself as working on that branch. When you commit, it will move the bookmark to the newly created changeset.
我尝试了此操作,但最终却同时移动了两个书签.
I tried this, but it ended up moving both bookmarks at the same time.
是在指导错误,过时的操作,还是我做错了什么?请注意,我知道在单独的分支上具有书签只会移动与我当前正在使用的分支相关的书签,但是该指南(很多人说这是明确的指南)明确指出了上面的文字,这表明应该通过告诉" Mercurial来工作,该书签(分支)是我正在处理的.
Is that guide wrong, outdated, or did I do something wrong? Note that I know that having bookmarks on separate branches only moves the bookmark related to the branch I'm currently working on, but that guide (which a lot of people says is the definite guide to this) specifically says the above text, which indicates that it should've worked by "telling" Mercurial which bookmark (branch) I'm working on.
不过测试显示还是相反.
Testing shows otherwise though.
有什么想法吗?
示例:
> hg init
> echo 1 >test.txt
> hg commit -m "initial" --addremove
adding test.txt
> hg bookmark main
> hg bookmark feature
> hg log
changeset: 0:c56ceb49ee20
tag: feature
tag: main
tag: tip
user: Lasse V. Karlsen <lasse@vkarlsen.no>
date: Tue Nov 30 23:06:16 2010 +0100
summary: initial
> hg update feature
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> echo 2 >test2.txt
> hg commit -m "feature 1" --addremove
adding test2.txt
> hg log
changeset: 1:9f2f5869b57b
tag: feature <---- both were moved
tag: main <----
tag: tip
user: Lasse V. Karlsen <lasse@vkarlsen.no>
date: Tue Nov 30 23:06:45 2010 +0100
summary: feature 1
changeset: 0:c56ceb49ee20
user: Lasse V. Karlsen <lasse@vkarlsen.no>
date: Tue Nov 30 23:06:16 2010 +0100
summary: initial
推荐答案
如果我答对了,您希望仅更新的书签在下一次提交时继续进行.为此,书签扩展具有track.current
选项.
If I got you right, you want only the bookmark you've updated to move on the next commit. For this purpose the bookmarks extensions has the track.current
option.
来自书签扩展:
默认情况下,当几个书签指向同一个变更集时,它们将一起前进.通过将以下配置选项添加到您的.hgrc
By default, when several bookmarks point to the same changeset, they will all move forward together. It is possible to obtain a more Git-like experience by adding the following configuration option to your .hgrc
[bookmarks]
track.current = True
在您的示例中,这会将 main 书签保留在修订版0.
In your example, this would keep the main bookmark at revision 0.
如果启用了track.current
选项,则在hg bookmarks
的输出中,当前活动的书签将带有星号注释.
If the track.current
option is enabled, the currently active bookmark is annotated with an asterisk in the output of hg bookmarks
.
更新:自Mercurial 1.8以来,默认行为是仅移动当前书签,即,不再需要上述选项
UPDATE: Since Mercurial 1.8 the default behavior is to only move the current bookmark, i.e. the above mentioned option is not needed anymore [1].
这篇关于Mercurial,“带有书签的分支";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!