如何将文本合并在一起?就像版本控制系统一样?
维基百科说这非常好: http://en.wikipedia.org/wiki /Merge_(revision_control)#Three-way_merge
但是如何实现这一点呢?或者是否有 Ruby on Rails 的 gem/插件可以帮我处理这个问题?
我的情况:
• 我有基础文本
• A 的改变
• B 的变更
• 这两项更改都应包含在内,并且不覆盖其他
我可以指出的任何方向?谢谢!
Wikipedia says this is pretty good: http://en.wikipedia.org/wiki/Merge_(revision_control)#Three-way_merge
But how does one implement that? or are there any gems / plugins for Ruby on Rails that will handle that for me?
My situation:
• I have base text
• changes from person A
• changes from person B
• both changes should be included and not overriding the other
any directions I could be pointed in? thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你应该再次看看 merge3 gem [来源]。
这个小例子解释了它:
它生成的输出是:
我不确定它如何处理合并冲突,并且由于它应该处理文件的 3 路合并,因此它似乎是基于行的。如果这是一个问题(因为您的示例尝试比较简单的字符串),您可以在每个字符之间添加换行符。
希望这有帮助。
I think you should look at the merge3 gem again [source].
This small example explains it:
The output it generates is:
I am not sure how it handles merge conflicts, and since it is supposed to handle 3-way merges of files, it seems to be line-based. If that is a problem (as your example tries to compare simple string), you could add a newline between every character.
Hope this helps.
如果您正在存储希望能够合并的版本化文本,那么听起来您有一个调用版本控制系统的完美用例。将文本存储在文件中并调用 VCS 进行版本控制操作(也许 Git 或 Grit gems 会有所帮助)。
If you're storing versioned text that you want to be able to merge, then it sounds like you have a perfect use case for calling a version control system. Store the text in files and call the VCS for version control operations (perhaps the Git or Grit gems would be helpful).