让 Mercurial 使用自定义合并工具进行自己的合并



Mercurial 文档,说明当它必须进行 3way 合并时 mercurial 会做什么:

默认情况下,Mercurial 将尝试对文本进行经典的 3 向合并 文件在尝试使用外部工具之前在内部文件。

当它调用外部工具时,这始终是"手动合并"。

并非所有的合并工具

都是平等创建的,事实证明,我选择的合并工具(Araxis Merge)通常能够自动合并3个文件,而Mercurial的内部合并工具无法做到这一点。

这导致了大合并的情况,其中可能有一堆文件干净地合并,由 hg 的内部合并工具完成,然后其他一些文件不能干净地合并,但如果 hg 让我指定它的合并工具,可能会有。我发现这使得大型合并效率非常低,因为您需要大量上下文切换:hg 弹出我的合并工具,我认为"哦,的,冲突",然后意识到"哦,等等,根本没有冲突"

想知道我是否在这里遗漏了一些东西,或者是否真的没有办法让 hg 能够使用自定义合并工具自动尝试进行合并。

我认为您正在寻找一个开关,以使Araxis Merge在可以自动合并时自动关闭自己。我查看了命令行参考及其 SCM 集成文档,但我实际上不确定它会是什么开关。你必须自己做实验。

从Mercurial的角度来看,没有"手动合并"这样的东西。Mercurial 首先尝试内部合并(所谓的"预合并"步骤),如果失败,它会寻找外部工具。如果该工具存在且退出代码为零(成功退出),则合并仍然可以是完全自动的。然后,Mercurial 将认为合并成功并继续下一个文件。根据工具的不同,您根本不会注意到这一点:Mercurial 只是在后台运行该工具,只有在发生严重的合并冲突时才会提示您采取行动。

您可以将自定义合并工具与 Mercurial 一起使用。 help 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.
2. If the "HGMERGE" environment variable is present, its value is used and
   must be executable by the shell.
3. 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.
4. 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.
5. If any usable merge tools are present in the merge-tools configuration
   section, the one with the highest priority is used.
6. 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.
7. If the file to be merged is not binary and is not a symlink, then
   "internal:merge" is used.
8. The merge of the file fails and must be resolved before commit.

更多信息可以在help config中找到 - 查找merge-toolsmerge-patterns

最新更新