使用 hg pull/push/merge/graft 将更改标记为已合并或故意忽略?
我正在从 Subversion 过渡到 Mercurial,在那里我习惯使用 svnmerge.py 来跟踪已合并的更改,或已阻止合并的更改:
# Mark change 123 as having already been merged; it will not be merged again, even if a range
# that contains it is subsequently specified.
svnmerge.py merge -M -r123
#
# Block change 326 from being considered for merges.
svnmerge.py merge -X -r326
#
# Show changes that are available for merging from the source branch.
svnmerge.py avail
#
# Do a catchall merge of the remaining changes. Neither change 123 nor change 326 will be
# considered for merging.
svnmerge.py merge
我希望能够对 hg pull/ 执行类似的操作推送/合并/移植,这样,如果我知道我永远不想合并给定的更改,我可以阻止它考虑,使后续的挑选、合并等变得更加“一劳永逸”事务。我已经做了很多谷歌搜索,但还没有找到一种方法来做到这一点。
似乎也无法查看尚未移植的更改列表。
由于我经常在其他开发人员之后进行整理并帮助他们进行合并,因此能够做这些事情非常有帮助,人们很可能会认为这是“逆向挑选”;即,标记您不想合并的更改,然后对其余部分进行批量合并。
I'm transitioning to Mercurial from Subversion, where I'm used to using svnmerge.py to track changes that have already been merged, or which have been blocked from being merged:
# Mark change 123 as having already been merged; it will not be merged again, even if a range
# that contains it is subsequently specified.
svnmerge.py merge -M -r123
#
# Block change 326 from being considered for merges.
svnmerge.py merge -X -r326
#
# Show changes that are available for merging from the source branch.
svnmerge.py avail
#
# Do a catchall merge of the remaining changes. Neither change 123 nor change 326 will be
# considered for merging.
svnmerge.py merge
I want to be able to do something similar for hg pull/push/merge/graft, so that if I know that I never want to merge a given change, I can just block it from consideration, making subsequent cherry-picking, merging, etc., into a more fire-and-forget affair. I have done a lot of googling, but have not found a way to do this.
There also appears to be no way to view a list of as-yet-ungrafted changes.
As I'm often tidying up after other developers and helping them with their merges, it's immensely helpful to be able to do these kinds of things, which one might well consider "inverse cherry-picking;" i.e., marking changes that you do NOT want to merge, and then doing a bulk merge of the remainder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基于 DAG 的系统(例如 Mercurial 和 Git)要么全有要么全无:当您合并两个分支时,您会对共同祖先和两个分支进行三向合并。
三向合并仅关注每个分支的最后阶段。例如,如果您在 10 到 1000 步中进行更改并不重要 - 合并结果将是相同的。
这意味着忽略变更集的唯一方法是在合并之前将其取消:
这将取消分支上的变更集,从三向合并的角度来看,它看起来似乎从未进行过。
如果您有一个想要合并的整个分支,但忽略了,那么您可以执行虚拟合并:
它会执行合并,但会恢复到提交之前的旧状态。
我能给你的最好建议是构建你的工作流程,这样就不需要上述的取消了。这意味着在最旧的应用分支上提交错误修复。如果在创建功能 X 时发现错误,则使用
hg bisect
来确定错误是何时引入的。现在更新回您仍想修复错误的最旧分支:然后将错误修复合并到所有后续分支中:
如果错误修复不再适用,那么您应该仍然合并,但扔掉不相关的更改:
这确保您始终可以
查看 2.2 分支上尚未合并到 3.0 中的变更集。
DAG-based systems like Mercurial ans Git are all or nothing: when you merge two branches, you do a three-way merge of the common ancestor and the two branches.
The three-way merge is only concerned with the final stage of each branch. For instance, it doesn't matter if you make your changes in 10 it 1000 steps — the merge result will be the same.
This implies that the only way to ignore a changeset is to back it out before the merge:
That will cancel the changeset on the branch, making it appear that it was never made from the perspective of the three-way merge.
If you have a whole branch that you want to merge, but ignore, then you can do a dummy merge:
That goes through the merge, but reverts back to the old state before committing.
The best advice I can give you is to structure your workflow so that the above backouts aren't necessary. This means committing a bugfix on the oldest applicative branch. If a bug is found while creating feature X, then use
hg bisect
to figure out when the bug was introduced. Now updated back to the oldest branch where you still want to fix the bug:then merge the bugfix into all later branches:
If the bugfix no longer applies, then you should still merge, but throw away the unrelated changes:
That ensures that you can always use
to see changesets on the 2.2 branch that haven't been merged into 3.0 yet.