Mercurial:应用从稳定命名分支到开发分支的错误修复更改
我的仓库中有这两个命名分支。稳定且开发。我的问题是如何将稳定版中更改的错误修复补丁复制到开发分支?我真的很想在框架内执行此操作,而不是使用任何扩展:)
编辑
我为这个问题设置了赏金,因为我真的想要解决方案。有一个很好的解决方案,但中途被搁置了。所以我别无选择。现在看来已经有了答案。但我会在另一天让这个问题公平化,以防万一有人有更好的解决方案。希望这是有道理的。 :)
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? 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. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
补充 蒂姆的答案,另一种处理方法是 Mercurial 建议您这样做,如果可以的话,提前计划(我会看看是否可以整理出一个链接。)
该计划是,如果您知道错误修复/更改必须进入多个分支,则您不会将该更改集一开始就提交到其中一个位置,而是在其他地方进行。
由于您正在修复错误,因此在项目历史的某个位置引入了该错误。
由于错误修复需要进入多个分支,因此该“某处”必须位于分支点之前,否则该错误不会出现在两个(/所有)分支中。
因此,推荐的方法是修复引入错误的位置,然后将该变更集合并到每个需要它的分支中。
让我们看一个例子,我们有
default
和stable
分支:然后你发现变更集 2 引入了一个 bug,并且需要将 bugfix 应用于两个
default
和稳定
。按照您在问题中描述的方式,您似乎会这样做:但这也会将变更集 13 合并到
default
中。如果您不希望这种情况发生,您可以这样做:有关如何在错误修复场景中使用 Mercurial 的更多信息,《Mercurial:权威指南》的第 9 章非常值得一读。
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.)
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
andstable
branches:Then you discover that changeset 2 introduced a bug, and the bugfix needs to be applied to both
default
andstable
. The way you describe it in the question, it looks like you would do this:But this would merge changeset 13 into
default
as well. If you don't want that to happen, you would instead do this:For more information on how to use Mercurial in bugfixing-scenarios, the 9th Chapter of 'Mercurial: The Definitive Guide' is well worth the read.
如果您的
dev
分支是您的“稳定命名分支”的后代,那么您可以简单地如果这不可行,那么最自然的答案是
移植
扩展。此扩展随 Mercurial 一起分发,因此您只需在mercurial.ini
或.hgrc
中添加一行即可启用它。启用它后,您可以:如果您确实想避免使用扩展程序,那么您可以使用
导出
和导入< /代码>
:
If your
dev
branch is a descendant of your "stable named branch", then you could simplyIf this is not feasible, then the most natural answer is the
transplant
extension. This extension is distributed with Mercurial, so you only need to add a single line to yourmercurial.ini
or.hgrc
to enable it. With it enabled, you can:If you really want to avoid using an extension, then you could use
export
andimport
:移植扩展很好地实现了这一点 - 正是您想要的
Transplant extension do the trick nicely - and exactly that you want