Mercurial如何在内部合并? [英] How does Mercurial merge internally?

查看:99
本文介绍了Mercurial如何在内部合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于quora,有一篇关于git如何合并的漂亮文章: http://www.quora.com/Git-revision -control/How-does-git-merge-work

There is a nifty article on quora about how git does it's merging: http://www.quora.com/Git-revision-control/How-does-git-merge-work

我想知道Mercurial是否存在这样的事情.

And I was wondering if such a thing existed for Mercurial.

我承认我这样做的动机是Mercurial对于自动解决冲突似乎很愚蠢,但是如果没有关于Mercurial如何合并的具体信息,我无法为Git争论. (也许我疯了,方法也一样,不管我在任何地方都找不到有关HG如何合并的信息.)

I'll admit that my motivation for this is that Mercurial seems really dumb about auto-resolving conflicts, but without concrete information about how mercurial does it's merging, I can't form an argument for Git. (Also maybe I'm crazy and the method is the same, regardless I can't find the information about how HG merges, anywhere.)

我也听说HG是超级可配置的,所以如果有一种工具可以使合并变得更简单,那么我很想听听它.

Also I hear HG is super configurable, so if there is a tool to make the merging less dumb, I would love to hear about it.

作为HG似乎表现出的愚蠢行为的一个例子,它与其他空白对象产生了许多冲突,例如:

As an example of the silliness HG appeared to do, it gave a number of conflicts with other empty, such as:

<<<<<<<< local
[some new code...]
========
>>>>>>>> other

因此,我也在寻找一种可以智能地自动解决冲突的合并工具.就像,它应该能够解决上面的示例,而这个示例很容易解决.

So, I'm also looking for a merge tool that can intelligently auto-resolve conflicts. Like, it should be able to resolve the above example, which is painfully simple to resolve.

推荐答案

Mercurial在很大程度上与外部程序合并.参见

Mercurial largely leaves merging to an external programs. See

https://www.mercurial-scm.org/wiki/MergeToolConfiguration

https://www.mercurial-scm.org/repo /hg/help/merge-tools

从最后一页开始:

Mercurial在决定使用哪种合并工具时会使用以下规则:

Mercurial uses these rules when deciding which merge tool to use:

  1. 如果已使用--tool选项指定了工具以合并或 解决,它被使用.如果它是merge-tools中的工具名称 配置,使用其配置.否则指定工具 必须由外壳程序执行.

  1. If a tool has been specified with the --tool option to merge or resolve, it is used. If it is the name of a tool in the merge-tools configuration, its configuration is used. Otherwise the specified tool must be executable by the shell.

如果环境变量"HGMERGE" 存在时,将使用它的值,并且该值必须可由Shell执行.

If the "HGMERGE" environment variable is present, its value is used and must be executable by the shell.

如果要合并的文件的文件名与中的任何模式匹配 合并模式配置部分,第一个可用的合并工具 对应于匹配模式.在这里,二进制功能 不考虑合并工具的功能.

If the filename of the file to be merged matches any of the patterns in the merge-patterns configuration section, the first usable merge tool corresponding to a matching pattern is used. Here, binary capabilities of the merge tool are not considered.

如果设置了ui.merge,它将是 考虑下.如果该值不是已配置工具的名称, 指定的值已使用,并且必须可由Shell执行. 否则,将使用命名工具(如果可用).

If ui.merge is set it will be considered next. If the value is not the name of a configured tool, the specified value is used and must be executable by the shell. Otherwise the named tool is used if it is usable.

如果合并工具配置中存在任何可用的合并工具 部分中,使用优先级最高的那个.

If any usable merge tools are present in the merge-tools configuration section, the one with the highest priority is used.

如果可以命名为"hgmerge"的程序 可以在系统上找到它,但是默认情况下将不使用它 用于符号链接和二进制文件.

If a program named "hgmerge" can be found on the system, it is used - but it will by default not be used for symlinks and binary files.

如果要合并的文件不是二进制文件也不是符号链接,则 使用内部:合并".

If the file to be merged is not binary and is not a symlink, then "internal:merge" is used.

8.文件合并失败,必须在提交之前解决.

8.The merge of the file fails and must be resolved before commit.

注意:选择合并程序后,默认情况下,Mercurial将尝试 首先使用简单的合并算法合并文件.只有当它不 由于冲突更改而成功,Mercurial实际上将执行 合并程序.是否先使用简单合并算法可以 由合并工具的premerge设置控制.预先合并为 除非文件是二进制文件或符号链接,否则默认情况下处于启用状态.

Note: After selecting a merge program, Mercurial will by default attempt to merge the files using a simple merge algorithm first. Only if it doesn't succeed because of conflicting changes Mercurial will actually execute the merge program. Whether to use the simple merge algorithm first can be controlled by the premerge setting of the merge tool. Premerge is enabled by default unless the file is binary or a symlink.

这篇关于Mercurial如何在内部合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆