为什么Mercurial不需要“递归合并策略”?
AFAIK git 的默认合并策略是“递归”,这意味着当多个“共同祖先”最终成为“好的候选者”时,git 会将它们合并并为贡献者创建一个新的“虚拟共同祖先”。它基本上有助于解决文件已经合并的情况,并避免再次合并它们或出现不正确的合并贡献者。
我的问题是:如果Mercurial不使用“递归”,它如何处理同样的情况?
谢谢
AFAIK git's default merge strategy is "recursive" which means when more than one "common ancestor" ends up being a "good candidate", git will merge them and create a new "virtual common ancestor" for the contributors. It basically helps solving situations where files were already merged and it avoids merging them again or coming up with incorrect merge contributors.
My question is: if Mercurial doesn't use "recursive", how does it handle the same situation?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大多数版本控制系统不知道如何处理有多个基础版本可供合并的情况。数学合并方程为
Result = Destination + SumOf(I=1-N)(Base(I) - Source(I))
在大多数情况下 N=1,您会得到与源的经典合并,典型的三向合并工具可以处理的目标版本和基本版本。尽管许多源代码控制系统甚至在这种简单的情况下也没有用于查找基本版本的正确算法。为此,您需要沿着合并箭头向上追溯版本树,直到遇到共同的祖先。但有时共同祖先太远,不适合上面的等式 N=1,在这种情况下,您需要为多个部分合并找到多个共同祖先。
示例是一个分支被向下和向上合并多次的情况,然后我们尝试将更改从该分支交叉合并到另一个分支。在这种情况下,N>1。 1,但低于源分支上的合并次数。
这是分支合并中最难做的事情之一,我不知道有哪个源代码控制系统能够真正正确地做到这一点。
Most version control system do not know how to handle a situation where there is multiple base versions for a merge. The math merge equation is
Result = Destination + SumOf(I=1-N)(Base(I) - Source(I))
In most cases N=1 and you got a classic merge with source, destination and base versions which a typical 3-way merge tool can handle. Although many source control systems do not have even in this simple case a correct algorithm for finding the Base version. To do so you need to trace back through version tree going up the merge arrows, until you meet at a common ancestor. But sometimes the common ancestor is too far, not fitting the equation above for N=1 and in that case you need to find multiple common ancestors for multiple partial merges.
Example would be a case where a branch is merged down and up multiple times, then we try to cross merge the changes from this branch to another branch. In such case the N > 1, but lower than the number of merge downs on the source branch.
This is one of the hardest thing to do in branch merging and I don't know a source control system that actually does it correctly.
Mercurial 的原作者写了为什么他不使用递归合并策略(链接):基本上答案是:
但是完整的 答案读起来真的很有趣,所以我鼓励你这样做。我将其复制到这里以防它消失:
The original author of Mercurial wrote about why he didn't use recursive merge strategy (link): Basically the answer is:
But the full answer is really interesting to read so I encourage you to do so. I'll just copy it here in case it disappear: