问题描述
所以我一直在开发一个 wiki 类型的网站.我要决定的是,合并同时由两个用户编辑的文章的最佳算法是什么.
So I've been working on a wiki type site. What I'm trying to decide on is what the best algorithm for merging an article that is simultaneously being edited by two users.
到目前为止,如果两个不相关的区域被编辑,我正在考虑使用维基百科的方法合并文档,但如果两个提交发生冲突,则丢弃旧的更改.
So far I'm considering using Wikipedia's method of merging the documents if two unrelated areas are edited, but throwing away the older change if two commits conflict.
我的问题如下:如果我有原始文章,并对其进行了两次更改,合并它们然后在出现冲突时处理冲突的最佳算法是什么?
My question is as follows: If I have the original article, and two changes to it, what are the best algorithms to merge them and then deal with conflicts as they arise?
推荐答案
Bill Ritcher 的优秀论文A Trustworthy 3-Way Merge"讨论了商业 SCM 包使用的一些常见问题,包括三路合并和巧妙的解决方案.
Bill Ritcher's excellent paper "A Trustworthy 3-Way Merge" talks about some of the common gotchas with three way merging and clever solutions to them that commercial SCM packages have used.
三向合并将自动应用每个版本的所有更改(不重叠).诀窍是自动处理尽可能多的几乎重叠的区域.
The 3-way merge will automatically apply all the changes (which are not overlapping) from each version. The trick is to automatically handle as many almost overlapping regions as possible.
这篇关于文本的三路合并算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!