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 with another suffix (say *.mdl). The purpose of this is to allow me to employ a type of 'clobber merge' for a specific file type (ie: un-mergable files like configurations, auto-generated C, models, etc..)
In my .hgrc I've tried:
开发者_C百科[merge-tools]
kdiff3=
clobbermerge=internal:other
clobbermerge.premerge = False
[merge-patterns]
**.c = kdiff3
**.h = kdiff3
**.mdl = clobbermerge
but it still triggers kdiff3 for all files. Thoughts?
An extension of this would be to perform a 'clobber merge' on a directory - but once the syntax is clear for a file suffix, the dir should be easy.
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
According to this Mercurial MergeToolConfiguration page, you should put the interal:other
directly after the match pattern:
[merge-patterns]
**.mdl = internal:other
精彩评论