[英]Mercurial: Back out public changesets and reapply to new public branch?
We're using Kiln and Fogbugz; 我们正在使用Kiln和Fogbugz; Kiln is supposed to seamlessly allow git and hg to work together. 窑应该无缝地允许git和hg一起工作。 However, we've run into an issue where git branches are treated like bookmarks in mercurial; 但是,我们遇到了一个问题,即git分支被当作书签保存。 we didn't catch this in our repo until changes had been pushed, and now the branches are a bit polluted. 直到推动更改,我们才在回购中发现了这一点,现在分支已经被污染了。
I have public changesets in our default branch that should be in a custom branch. 我在默认分支中有公共变更集,应该在自定义分支中。 I can back them out, but I need to reapply them to the other public branch. 我可以撤消它们,但是我需要将它们重新应用于其他公共分支。 I'm worried about rebasing because these are public changes. 我担心变基,因为这些是公共更改。
What's the best way to handle this situation? 处理这种情况的最佳方法是什么?
Edit: I thought I might be able to convert the changesets to a patch using mercurial queues, but the changesets aren't mutable since they're public. 编辑:我以为我可以使用Mercurial队列将变更集转换为补丁,但是变更集是不可变的,因为它们是公开的。 I also can't do hg strip for similar reasons. 由于类似的原因,我也不能做汞剥离。
In Mercurial, you use hg graft
to copy (also sometimes called cherry pick ) changesets from one place to another. 在Mercurial中,您可以使用hg graft
将变更集(有时也称为Cherry Pick )从一个地方复制到另一个地方。 It is frequently used to backport a bugfix to a maintenance branch when the bugfix was committed on the wrong branch by accident. 当错误修正是偶然地提交到错误分支时,通常用于将错误修正移植回维护分支。
You use it like this: 您可以这样使用它:
$ hg update correct-branch
$ hg graft your-commit
This will recreate your-commit
as a child of correct-branch
, similarly to importing your-commit
into MQ, popping the patch, updating to correct-branch
and pushing the patch. 这将把your-commit
重新创建为correct-branch
的子correct-branch
,类似于将your-commit
导入到MQ中,弹出补丁,更新为correct-branch
并推送补丁。 The advantage of graft is that it will use three-way merges internally to give you much better conflict resolution. 嫁接的好处是它将在内部使用三向合并来为您提供更好的冲突解决方案。 It is really the same way that hg rebase
works. hg rebase
工作原理实际上是相同的。
I'd like to promote torek's comment to a full-fledged answer to make it more visible. 我想将torek的评论提升为一个完整的答案,以使其更明显。
As he notes, the hg phase
command (with the --force flag) can repair the situation when mercurial thinks the changeset has been made public. 正如他所指出的那样,当mercurial认为变更集已公开时, hg phase
命令(带有--force标志)可以修复这种情况。 Of course you want to make very sure you're right about whether it has been shared first. 当然,您要非常确定是否首先共享它是正确的。
I ran into a glitch where mercurial marked an unpushed branch as public, and this made it easy to fix with qimport (or could have used strip.) 我遇到了一个小故障,在该故障中,mercurial将未推送的分支标记为公共,这使得使用qimport轻松修复(或可能使用了strip)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.