在Mercurial中移动分支开始 [英] Move branch start in Mercurial

查看:78
本文介绍了在Mercurial中移动分支开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题类似于 Mercurial将更改更改为新分支,但不完全相同.

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

所以 default 现在有两个打开的头:7和4.我想摆脱打开的头4,但是当然还有3和4合并回到"main"中 default 稍后,当我们将 newbranch 合并回main时(现在不希望将它们合并,因为这会导致我们不希望在 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 ?

在5上执行--close-branch,在2上创建新分支,然后重新应用3-5版?

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

据我所知,没有简单的方法来简单地说"newbranch从3开始而不是从5开始" .

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

更新:由于其他人已经撤消了此建议,因此我不想为有问题的修订打下基础.强迫同事重新创建/切换分支是可以的,因为那样只会影响一个人,而不是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.

推荐答案

要摆脱多余的默认标题,您可以:

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."

当您最终合并newbranch时,它将包括3-5修订版以及您在5之上提交的任何其他修订版.

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

唯一的潜在问题是版本3-4将不会被标记为命名分支的一部分.如果这对您确实很重要,那么您应该同时关闭额外的默认标题和newbranch标题,并从以版本2为根的新分支重新开始.

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.

这篇关于在Mercurial中移动分支开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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