简体   繁体   English

mercurial:将错误的更改从稳定的命名分支应用于dev分支

[英]mercurial: apply a bugfix change from stable named branch to dev branch

i have these two named branches in my repo. 我的仓库中有这两个命名的分支。 Stable and dev. 稳定和开发。 My question is how do i copy a bugfix patch that was changed in stable to the dev branch? 我的问题是如何将稳定更改的错误修正补丁复制到dev分支? i would really like to do this within the framework and not with any extension :) 我真的很想在框架内而不是任何扩展:)

EDIT 编辑

I set a bounty for the question because i really wanted the solution. 我为这个问题设置了赏金,因为我真的想要解决方案。 There was a nice solution but was left mid way. 有一个不错的解决方案,但还没完成。 So i had no other option. 所以我别无选择。 It now appears to have been answered. 现在看来已经被回答了。 But i will let the question fair another day, just in case someone has a better solution. 但是,如果有人有更好的解决方案,我将在第二天让这个问题公平。 Hope that makes sense. 希望有道理。 :) :)

To augment Tim's answer , a different way to approach it is how the Mercurial recommend you do it if you can, plan ahead (I'll see if I can rustle up a link.) 为了扩大蒂姆的答案 ,另一种解决方法是Mercurial建议您尽可能做到这一点,并提前计划(我会看看是否可以建立一个链接)。

The plan goes that if you know that a bugfix/change has to go into several branches, you don't commit that changeset into one of those places to begin with, you do it somewhere else. 该计划的目的是,如果您知道一个错误修正/更改必须进入几个分支,则无需将该更改集提交到其中一个开始的地方,而可以在其他地方进行。

Since you're fixing a bug, somewhere in the history of the project, that bug was introduced. 由于您要修复错误,因此在项目历史记录中的某个位置引入了该错误。

And since the bugfix needs to go into more than one branch, that "somewhere" has to be before the point where you branched, otherwise the bug wouldn't be in both (/all) branches. 并且由于该错误修复程序需要进入多个分支,因此该“某处”必须在分支点之前,否则该错误将不会同时出现在两个(/所有)分支中。

So, the recommended way is to fix the bug where it was introduced, and then merge that changeset into each of the branches that needs it. 因此,推荐的方法是修复引入错误的位置,然后将该变更集合并到需要它的每个分支中。

Let's look at an example, we have default and stable branches: 让我们看一个示例,我们有default分支和stable分支:

1---2---3---4---5---6---7---8---9---10       default
         \               \
          \               \
           11--------------12--13            stable

Then you discover that changeset 2 introduced a bug, and the bugfix needs to be applied to both default and stable . 然后,您发现changeset 2引入了一个错误,并且该错误修正需要同时应用于defaultstable The way you describe it in the question, it looks like you would do this: 在问题中描述它的方式看起来像是要这样做:

1---2---3---4---5---6---7---8---9---10--15       default
         \               \             /^-- merge stable into default
          \               \           /
           11--------------12--13----14          stable
                                     ^-- bugfix

But this would merge changeset 13 into default as well. 但这也会将变更集13合并为default If you don't want that to happen, you would instead do this: 如果您不希望发生这种情况,则可以这样做:

       v-- bugfix
       14--------------------------+--+
      /                            |   \
     /                             |    \
1---2---3---4---5---6---7---8---9--x-10--15       default
         \               \         |     ^-- merge 14 into default
          \               \        |
           11--------------12--13--16             stable
                                   ^-- merge 14 into stable

For more information on how to use Mercurial in bugfixing-scenarios, the 9th Chapter of 'Mercurial: The Definitive Guide' is well worth the read. 有关如何在错误修复场景中使用Mercurial的更多信息,非常值得一读的“ Mercurial:权威指南”第9章

If your dev branch is a descendant of your "stable named branch", then you could simply 如果您的dev分支是“稳定命名分支”的后代,那么您只需

hg update dev
hg merge stable

If this is not feasible, then the most natural answer is the transplant extension . 如果这不可行,那么最自然的答案就是transplant扩展 This extension is distributed with Mercurial, so you only need to add a single line to your mercurial.ini or .hgrc to enable it. 该扩展名与Mercurial一起分发,因此您只需在mercurial.ini.hgrc添加一行即可启用它。 With it enabled, you can: 启用它,您可以:

hg update dev
hg transplant --log <rev>

If you really want to avoid using an extension, then you could use export and import : 如果您确实想避免使用扩展名,则可以使用exportimport

hg export --rev <rev> > tmp.patch
hg update dev
hg import tmp.patch

移植扩展可以很好地解决问题-正是您想要的

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

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