将 Mercurial 中一个分支的选定修订合并到另一个分支
是否可以在 Mercurial 中将一系列修订从一个分支合并到另一个分支?
例如,
|r1
|r2
|r3
|\___
| | r5
| | r6
| | r7
| | ...
| | r40
|r41
如果我想合并修订版 6 & 7,但不是 5,进入主分支 - 这可能吗?
这样的合并可能是微不足道的,例如,如果 r5 修改了在 6 和 r5 中未修改的文件。 7(因此,如果不需要,可以安全地忽略其更改)
从分支 A 到分支 B 的多个选定修订范围怎么样?例如合并 4-7、20-25 和 30-34?
(这不是一个真实的案例,只是一个例子。我试图了解 hg 是否具有我知道 svn 具有的修订范围合并功能)
Is it possible to merge a range of revisions from one branch to another in Mercurial?
e.g.
|r1
|r2
|r3
|\___
| | r5
| | r6
| | r7
| | ...
| | r40
|r41
If I want to merge revisions 6 & 7, but not 5, into the main branch - is this possible?
Such a merge can be trivial, for example, if r5 modified files that are not modified in 6 & 7 (and so its changes, if not needed, can safely be ignored)
What about multiple selected revision ranges from branch A to branch B? e.g. merge 4-7, 20-25 and 30-34?
(this isn't a real case, just an illustration. I'm trying to understand if hg has this revision-range merge feature that I know svn has)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 Mercurial 的移植扩展,我认为它会完全满足您的需求。
https://www.mercurial-scm.org/wiki/TransplantExtension
Check out the Transplant extension for mercurial, I think it will do exactly what you want.
https://www.mercurial-scm.org/wiki/TransplantExtension
简单的答案是不。
这违背了 Mercurial 的精神。
您的图表暗示
6
依赖于5
,因此任何拉动6
的内容都应该拉动5
,否则就没有意义。在我看来,你在这里弄错了 Mercurial。如果您的变更树是线性的,则通常表明您正在使用 Mercurial,就像使用 CVS 或 SVN 一样。
您的更改树应该看起来更像:
然后您可以拉取从
5
开始的分支或从23
开始的分支。现在,错误是人为的,因此有一种称为导出的“工具”,它允许您从一个变更集创建一个简单的差异文件。
在您的具体情况下,您可以:
r4
r6
的差异,并创建与r7
的差异(导出r41
如果您愿意,您也可以走扩展之路。有几个有用的扩展可用于操作变更集。示例集:
例如,您可以在这里克隆存储库(重要的是,始终在克隆上测试它们,以防万一),然后折叠您感兴趣的范围。然后您可以导出/导入它们。
The simple answer is no.
This is contrary to the spirit of Mercurial.
Your graph implies that
6
depends upon5
so anything that pulls6
should pull5
also otherwise it makes no sense.It seems to me that you got Mercurial wrong here. If your change tree is linear, it's usually a sign that you are using Mercurial like you would use CVS or SVN.
Your change tree should look more like:
And then you could pull either the branch starting at
5
or the one starting at23
.Now, mistake is human, so there is a "facility" called export, which allow you to create a simple diff file from one changeset.
In your specific case, you would thus:
r4
r6
and one fromr7
(export)r41
If you wish, you can also go the extension road. There are several useful extensions for manipulating the changesets. A sample set:
Here you could for example clone the repository (important, always test these on clones, just in case) and then collapse the ranges you are interested in. Then you can export/import them.