Mercurial搬迁到新的分支机构 [英] Mercurial move changes to a new branch

查看:68
本文介绍了Mercurial搬迁到新的分支机构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些对本地存储库所做的更改,但尚未推送.由于功能花费的时间比预期的长,因此我想在推送之前将这些更改交换到命名分支上.我该怎么办?

I have a number of changes that I committed to my local repository, but have not yet been pushed. Since on a feature is taking longer than expected, I want to swap these changes onto a named branch before I push. How can I do this?

推荐答案

如Mark所建议的, MqExtension 是解决您问题的一种方法.恕我直言,一个更简单的工作流程是使用 rebase扩展.假设您有这样的历史记录:

As suggested by Mark, the MqExtension is one solution for you problem. IMHO a simpler workflow is to use the rebase extension. Suppose you have a history like this:

@  changeset:   2:81b92083cb1d
|  tag:         tip
|  summary:     my new feature: edit file a
|
o  changeset:   1:8bdc4508ac7b
|  summary:     my new feature: add file b
|
o  changeset:   0:d554afd54164
   summary:     initial

这意味着修订版0是您开始使用功能的基础.现在,您要在命名分支上具有修订版1-2,比方说my-feature.更新到修订版0并创建该分支:

This means, revision 0 is the base on which you started to work on your feature. Now you want to have revisions 1-2 on a named branch, let's say my-feature. Update to revision 0 and create that branch:

$ hg up 0
$ hg branch my-feature
$ hg ci -m "start new branch my-feature"

历史记录现在看起来像这样:

The history now looks like this:

@  changeset:   3:b5939750b911
|  branch:      my-feature
|  tag:         tip
|  parent:      0:d554afd54164
|  summary:     start new branch my-feature
|
| o  changeset:   2:81b92083cb1d
| |  summary:     my new feature: edit file a
| |
| o  changeset:   1:8bdc4508ac7b
|/   summary:     my new feature: add file b
|
o  changeset:   0:d554afd54164
   summary:     initial

使用rebase命令将修订版1-2移动到修订版3上:

Use the rebase command to move revisions 1-2 onto revision 3:

$ hg rebase -s 1 -d 3

这将产生以下图形:

@  changeset:   3:88a90f9bbde7
|  branch:      my-feature
|  tag:         tip
|  summary:     my new feature: edit file a
|
o  changeset:   2:38f5adf2cf4b
|  branch:      my-feature
|  summary:     my new feature: add file b
|
o  changeset:   1:b5939750b911
|  branch:      my-feature
|  summary:     start new branch my-feature
|
o  changeset:   0:d554afd54164
   summary:     initial

就这样..如Mark的答案注释中所述,通常在已经推送的变更集周围移动是个坏主意,除非您在一个能够沟通和执行历史操作的小团队中工作.

That's it .. as mentioned in the comments to Mark's answer, moving around already pushed changesets generally is a bad idea, unless you work in a small team where you are able to communicate and enforce your history manipulation.

这篇关于Mercurial搬迁到新的分支机构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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