将工作流“反向移植"到工作流程.变成不同的汞(Hg)分支? [英] Workflow to "backport" change into different Mercurial (Hg) branch?

查看:118
本文介绍了将工作流“反向移植"到工作流程.变成不同的汞(Hg)分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个负责人.一个是我们的主要开发负责人,另一个是我直到今天才忘记的一个人.我们发现了一个错误,并在我们的主要开发分支中对其进行了修复,而我只是意识到也应该在较早的分支中对其进行修复.

We have two heads. One is our main development head and the other is one that I forgot about until today. We found a bug and fixed it in our main development branch, and I just realized it should be fixed in the older branch as well.

我认为最好在较旧的分支上进行更改,然后将其与最新的分支合并,但我们没有那样做.汞可以处理吗?我们还没有尝试做过这样的事情,我也无法真正做到这一点.

I think it would have been better to make the change on the older branch and merge that with the up-to-date branch, but we didn't do it that way. Can mercurial handle this? We haven't tried to do anything like this and I can't really wrap my head around how it would be done.

推荐答案

是的,您有两个不错的选择:

Yes, you have two good options:

此版本引入了 graft命令,该命令可以向后移植更改一种聪明的方式. 智能"是它将在内部使用合并,这意味着您可以得到

This version introduced the graft command which can backport changes in an intelligent way. The "intelligence" is that it will use merges internally and this means that you get

  • 支持重命名:想象一下,您已修复了开发分支上文件foo.c中的错误.在较旧的维护分支中,foo.c被称为bar.c.使用hg graft,可以将对foo.c的更改正确合并到旧的bar.c中.

  • Support for renames: Imagine that you fixed the bug in file foo.c on the development branch. In the older maintenance branch foo.c was called bar.c. Using hg graft, the change to foo.c can be correctly merged into the old bar.c.

三向合并:嫁接涉及扭曲图形并合并在该临时图中.三向合并的优点是您可以使用常规的图形合并工具来解决冲突.

Three-way merges: Grafting involves twisting the graph around and merging in that temporary graph. The advantage of three-way merges is that you can use your normal graphical merge tool to resolve conflicts.

只需将default的尖端复制到old-branch,只需运行

To copy the tip of default onto old-branch you simply run

$ hg update old-branch
$ hg graft default

移植:旧版本

在我们执行嫁接命令之前,请先移植扩展是要走的路.这个简单的扩展会将变更集导出为补丁,并尝试将补丁应用到其他版本.

Transplant: older versions

Before we had the graft command, the transplant extension was the way to go. This simple extension will export a changeset as a patch and try to apply the patch onto some other revision.

因为我们正在处理哑"补丁,所以将不考虑重命名之类的事情,并且由于没有三向合并,因此您将无法获得对合并工具的支持.尽管如此,我发现移植在实践中确实非常有效.

Because we're dealing with "dumb" patches things like renames will not be taken into account and you will not get support for your merge tool since there is no three-way merge. Despite of this, I've found that transplant works really well in practice.

使用移植很简单:

$ hg update old-branch
$ hg transplant default

这非常接近运行

$ hg update old-branch
$ hg export default | hg import -

除了移植还添加了一段元数据,该元数据记录了移植的变更集中的原始变更集.这可以用来跳过将来的移植.

except that transplant also adds a piece of meta data that records the original changeset in the transplanted changeset. This can be used to skip future transplants.

这篇关于将工作流“反向移植"到工作流程.变成不同的汞(Hg)分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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