Mercurial merge strategy per file type

后端 未结 2 373

All:

I want to use kdiff to merge all files with a certain suffix (say *.c, *.h) and I want to do two things (turn off premerge and use internal:other) for all files

相关标签:
2条回答
  • 2021-01-20 11:19

    According to this Mercurial MergeToolConfiguration page, you should put the interal:other directly after the match pattern:

    [merge-patterns]
    **.mdl = internal:other
    
    0 讨论(0)
  • 2021-01-20 11:31

    Merge tools can use any executable file. To set up a merge tool which always overwrites $base with $other, you can use the following:

    [merge-tools]
    clobbermerge.priority = 100
    clobbermerge.premerge = False
    clobbermerge.args = $other $output
    clobbermerge.executable = <copy executable>
    

    When using this strategy on Windows, there is one problem. You cannot simply replace <copy executable> with the copy shell command. For some reason, Mercurial fails to find shell commands in this context. I have not tried this on *nix.

    To work around this problem, you can create a distribute a batch file that performs the copy. It simply needs to run: copy %1 %2. Once placed on your PATH, you can set clobbermerge.executable=clobber.bat.

    If you have kdiff3 installed (comes with TortoiseHg on Windows), you can get the same results without the external batch file using a configuration like this:

    [merge-tools]
    clobbermerge.priority = 100
    clobbermerge.premerge = False
    clobbermerge.args = --auto $base $other $other -o $output
    clobbermerge.executable = kdiff3
    

    The key to this configuration is the args field:

    • --auto: tells kdiff3 not to open the GUI if there are no conflicts
    • $base $other $other: tells kdiff3 to only use $other
    • $output: tells kdiff3 the name of the output file
    0 讨论(0)
提交回复
热议问题