What's the best way to close a Mercurial branch?

后端 未结 3 1891
忘掉有多难
忘掉有多难 2021-02-12 16:25

Is it better to first close a branch and then merge it with the default branch(for instance) or first merge it and then close it?

In TortoiseHg for instance, in the firs

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-12 16:39

    There is no real difference between the two methods when talking about named branches, at least in any recent version of Mercurial. Things were different pre-1.5(?), but purely in the fact that hg heads and hg branches would include these "closed" branches in their output - they still can if you specify -c on the command.

    Rememeber that when you close a branch (using hg commit --close-branch or in Tortoise) you effectively just commit a new changeset where the change has a flag set to say that branch X is closed - you can easily update to the branch and re-open it by performing another commit.

    However, when reopening a branch, the "bar" you see in Tortoise will still exist in the previously-closed changeset, and so for this reason alone I would personally opt for a close-then-merge policy. It is more visually instructive, I think, to see that you were merging from something you were happy with (and hence closed the branch prior to the merge).

    Things are slightly different with "anonymous" branches, in that they are not included in the hg branches output when they have been merged in, and so don't require explicit closing.

提交回复
热议问题