文本的三路合并算法
所以我一直在开发一个维基类型的网站。 我想要决定的是合并由两个用户同时编辑的文章的最佳算法是什么。
到目前为止,我正在考虑使用维基百科的方法,如果编辑了两个不相关的区域,则合并文档,但如果两个提交发生冲突,则丢弃旧的更改。
我的问题如下:如果我有原始文章,并且对其进行了两次更改,那么合并它们然后处理出现的冲突的最佳算法是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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.
本文用伪代码对 diff3 算法进行了形式化分析:
http://www.cis.upenn.edu/~bcpierce/papers/diff3-short。其
标题为“Diff3 的正式调查”,由来自雅虎的 Sanjeev Khanna、Keshav Kunal 和 Benjamin C. Pierce 撰写。
There's a formal analysis of the diff3 algorithm, with pseudocode, in this paper:
http://www.cis.upenn.edu/~bcpierce/papers/diff3-short.pdf
It is titled "A Formal Investigation of Diff3" and written by Sanjeev Khanna, Keshav Kunal, and Benjamin C. Pierce from Yahoo.
坦率地说,我会依赖 diff3。 几乎每个 Unix 发行版上都有它,您始终可以为 Windows 构建并捆绑一个 .EXE,以确保它适合您的用途。
Frankly, I'd rely on diff3. It's on pretty much every Unix distro, and you can always build and bundle an .EXE for Windows to ensure it is there for your purposes.