Move branch start in Mercurial

妖精的绣舞 提交于 2019-12-22 09:48:49

问题


My problem is similar to Mercurial move changes to a new branch, but is not exactly the same.

A colleague of mine started working on a new feature and issued a few local commits. Then he noticed "Oh well, that should go into a named branch" and thus created one. The problem is, the commits before should have been in that branch already. So the simplified history now looks a little like this:

O 7: default
|
O 6: default
|
|  O 5: newbranch
|  |
|  O 4: default
|  |
|  O 3: default
| /
O 2: default
|
O 1: default

So default now has two open heads: 7 and 4. I'd like to get rid of the open head 4 but of course still have 3 and 4 merged back into the "main" default later on when we merge newbranch back into main (merging them now is undesired as it would bring changes into default that we don't want there yet).

The question is: what's the best way to handle this ?

Do a --close-branch on 5, create a new branch off 2 and re-apply revisions 3-5 ?

As far as I've understood there's no good way to simply say "newbranch started at 3 instead of 5".

Update: Since this is has already been pulled by others I don't want to rebase the revisions in question. Forcing the colleague to recreate/switch branches would be OK since that would affect only one person instead of 5.


回答1:


To get rid of the extra default head, you could:

hg update -r 4
hg commit --close-branch -m "Closed extra default head.  The changes from this branch will be merged along with 'newbranch', once it is complete."

When you eventually merge newbranch, it will include revisions 3-5 plus any others that you commit on top of 5.

The only potential problem with this is that revisions 3-4 will not be labeled as part of the named branch. If this is really important for you, then you should close both the extra default head and the newbranch head and start over with a new branch rooted at revision 2.



来源:https://stackoverflow.com/questions/7596854/move-branch-start-in-mercurial

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!