如何正确关闭Mercurial中的功能分支? [英] How to correctly close a feature branch in Mercurial?

查看:61
本文介绍了如何正确关闭Mercurial中的功能分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了功能分支feature-x的工作.我想将结果合并回default分支并关闭feature-x以便在hg branches的输出中摆脱它.

I've finished working on a feature branch feature-x. I want to merge results back to the default branch and close feature-x in order to get rid of it in the output of hg branches.

我想出了以下情况,但是有一些问题:

I came up with the following scenario, but it has some issues:

$ hg up default
$ hg merge feature-x
$ hg ci -m merge
$ hg up feature-x
$ hg ci -m 'Closed branch feature-x' --close-branch

因此feature-x分支(changests 40-41)已关闭,但是有一个新的头部,关闭分支的变更集44,将在hg heads每次:

So the feature-x branch (changests 40-41) is closed, but there is one new head, the closing branch changeset 44, that will be listed in hg heads every time:

$ hg log ...
o  44 Closed branch feature-x
|
| @  43 merge
|/|
| o  42 Changeset C
| |
o |  41 Changeset 2
| |
o |  40 Changeset 1
|/
o  39 Changeset B
|
o  38 Changeset A
|

更新:看来,由于版本1.5 Mercurial不再在hg heads的输出中显示封闭分支的头.

Update: It appears that since version 1.5 Mercurial doesn't show heads of closed branches in the output of hg heads anymore.

是否可以关闭合并的分支而又不会留下另一个头?有更正确的方法来关闭功能分支吗?

Is it possible to close a merged branch without leaving one more head? Is there more correct way to close a feature branch?

相关问题:

推荐答案

一种方法是仅使合并的功能分支保持打开状态(并且处于非活动状态):

One way is to just leave merged feature branches open (and inactive):

$ hg up default
$ hg merge feature-x
$ hg ci -m merge

$ hg heads
    (1 head)

$ hg branches
default    43:...
feature-x  41:...
    (2 branches)

$ hg branches -a
default    43:...
    (1 branch)

另一种方法是在合并之前使用额外的提交关闭功能分支:

Another way is to close a feature branch before merging using an extra commit:

$ hg up feature-x
$ hg ci -m 'Closed branch feature-x' --close-branch
$ hg up default
$ hg merge feature-x
$ hg ci -m merge

$ hg heads
    (1 head)

$ hg branches
default    43:...
    (1 branch)

第一个比较简单,但是它留下了一个开放的分支.第二个没有留下开放的头/分支,但是它需要另外一个辅助提交.可以使用--close-branch将对功能分支的最后一次实际提交与此额外提交结合起来,但是应该提前知道哪个提交将是最后一次提交.

The first one is simpler, but it leaves an open branch. The second one leaves no open heads/branches, but it requires one more auxiliary commit. One may combine the last actual commit to the feature branch with this extra commit using --close-branch, but one should know in advance which commit will be the last one.

更新:自Mercurial 1.5起,您可以随时关闭该分支,因此该分支将不再出现在hg brancheshg heads中.唯一可能使您烦恼的是,从技术上讲,修订图仍然会有一个没有子项的修订.

Update: Since Mercurial 1.5 you can close the branch at any time so it will not appear in both hg branches and hg heads anymore. The only thing that could possibly annoy you is that technically the revision graph will still have one more revision without childen.

更新2 :自Mercurial 1.8以来,书签已成为Mercurial的核心功能.书签比命名分支更方便分支.另请参阅此问题:

Update 2: Since Mercurial 1.8 bookmarks have become a core feature of Mercurial. Bookmarks are more convenient for branching than named branches. See also this question:

这篇关于如何正确关闭Mercurial中的功能分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆