【问题标题】:Have Mercurial use a custom merge tool for its own merges让 Mercurial 使用自定义合并工具进行自己的合并
【发布时间】:2012-04-10 06:49:14
【问题描述】:

Mercurial 文档介绍了 mercurial 在必须进行 3 路合并时会做什么:

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

当它调用外部工具时,总是“手动合并”。

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

这导致了大合并的场景,其中可能一堆文件干净地合并,由 hg 的内部合并工具完成,然后其他一些文件没有干净地合并 但如果 hg 允许我指定它的合并工具。我发现这使得大合并非常低效,因为您需要进行很多上下文切换:hg 弹出我的合并工具,我认为“哦,该死,冲突”,然后实现“哦等等,根本没有冲突”

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

【问题讨论】:

    标签: mercurial merge


    【解决方案1】:

    我认为您正在寻找一个开关,如果 Araxis Merge 可以自动合并,它会自动关闭。我查看了command line reference 和他们的SCM integration document,但实际上我不确定它会是什么开关。您必须自己进行实验。

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

    【讨论】:

      【解决方案2】:

      您可以在 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-03-14
        • 2014-05-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-08
        相关资源
        最近更新 更多