mercurialmercurial-extension

hgext.extdiff silently does nothing


In trying to get my real differencing engine up, I've trimmed to a very minimal setup, but still have no output and no indication of why nothing appears to happen. (Search of SO and Mercurial site (including the mercurial wiki) for extdiff gave me all the ideas I've tried, though perhaps I haven't tried all.)

I have tried a bash script and a .bat file; I have tried each of the scripts located in the "root" of the E: drive, identified as /cygdrive/e/ or as E:/ I have tried with and without quoting the path to the script. I think I've exhausted the combinations and have yet to get any indications of what (if anything) is running. When invoked directly, FdbCmp.bat behaves as expected; it is in a directory on my $PATH and in the Windows Path environment variable.

Other suggestions? It looks like it is simple enough and should "just work"

mercurial.ini includes

[extdiff]  
hgext.extdiff
cmd.fdiff0 = "e:/Program Files/DbCmp/FdbCmp.bat"
opts.fdiff0 = $root --file $local --file $other

FdbCmp.bat:

@echo off
echo FdbCmp.bat testing
echo FdbCmp.bat args: ::%1:: ::%2:: ::%3 ::%4:: ::%5:: ::%6:: ::%7:: ::%8:: ::%9::

hg showconfig | grep extdiff returns the expected results (among a few other lines)

extdiff.cmd.fdiff0="e:/Program Files/DbCmp/FdbCmp.bat"  
extdiff.opts.fdiff0=$root --file $local --file $other  
extensions.hgext.extdiff=  

hg fdiff0 returns with $? = 0 (cygwin bash or CMD.EXE) and no output displayed. I expected the FdbCmp.bat file would have printed something.

hg fdiff0 a b c (where files a, b, c do not exist) returns the following. This is expected, as the files don't exist and Hg reports that.

a: The system cannot find the file specified  
b: The system cannot find the file specified  
c: The system cannot find the file specified  

hg fdiff0 file1 file2 file3 where all files exist returns with no error and no output. This is unexpected - FdbCmp.bat should have been invoked and printed its something.

Just testing the .bat file alone gives the expected results:
$ FdbCmp.bat moo cow oink pig

FdbCmp.bat testing  
FdbCmp.bat args: ::moo:: ::cow:: ::oink ::pig:: :::: :::: :::: :::: ::::  

hg --version is 2.4.6-35ba170c0f82


Solution

  • A re-read of the extdiff section of the documentation shows that options "will be inserted to the command between the program name and the files/directories to diff", unlike the merge-tools behaviour where options and files may be intermixed as required to build an appropriate comand line. The $local, $root, ... variables do not exist within the context of extdiff; they are merge-tools features that do not apply here.

    The relevant mercurial.ini section now is

    [extensions]
    # enable the extdiff extension
    hgext.extdiff =
    
    [extdiff]
    # define a jpeg differencing script; no options required
    cmd.jpgdiff = HgJpgDiff.bat
    # HgJpgDiff.bat is in a directory in my $PATH and contains:
    # @rem ... various lines to test if we have been handed directories or files to compare
    # @rem ...we only compare files, so this is the only active line
    # JpgDiff --file %1 --file %2
    
    [diff-patterns]
    **.jpg=jpgdiff
    

    and all works as desired now. Echoing parameters to a file helped to debug; nothing was ever displayed on the screen.

    Many thanks.