简体   繁体   English

“backport”的工作流程变为不同的Mercurial(Hg)分支?

[英]Workflow to “backport” change into different Mercurial (Hg) branch?

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? mercurial可以处理这个吗? 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: new in Mercurial 2.0 Graft:Mercurial 2.0中的新功能

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 “智能”是它将在内部使用合并,这意味着你得到

  • Support for renames: Imagine that you fixed the bug in file foo.c on the development branch. 支持重命名:想象一下,您修复了开发分支上文件foo.c的错误。 In the older maintenance branch foo.c was called bar.c . 在较旧的维护分支中, foo.c被称为bar.c Using hg graft , the change to foo.c can be correctly merged into the old bar.c . 使用hg graft ,对foo.c的更改可以正确地合并到旧的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. 三向合并的优点是您可以使用常规图形合并工具来解决冲突。

To copy the tip of default onto old-branch you simply run 要将default提示复制到old-branch您只需运行即可

$ 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. 尽管如此,我发现移植在实践中非常有效。

Using transplant is simple: 使用移植很简单:

$ hg update old-branch
$ hg transplant default

This is very close to running 这非常接近于运行

$ 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. 这可以用来跳过未来的移植。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM