Search code examples
mercurial

hg: unknown command 'extdiff''


I can't figure out why my extdiff extension is not working for Mercurial (on a Mac).

this is what my .hgrc file looks like:

[extensions]
fetch=
hgext.extdiff =

[extdiff]
cmd.kdiff3 =

[ui]
merge=kdiff3

[merge-tools]
kdiff3.executable=/Applications/kdiff3.app/Contents/MacOS/kdiff3
kdiff3.args = $base $local $other -o $output

and yet kdiff3 is recognized as a merge tool.. and can be run from the cmd line like "kdiff3". but what i'd like to do is use kdiff3 as a gui tool for comparing diff files.

like this: hg extdiff -p kdiff3

this seems like the best way of using kdiff3 as a popup gui when using Mercurial.

I am new to this and am not sure if I am doing it right.

Thanks...!

By the way, when I try to run 'hg extdiff'

I get:

 hg: unknown command 'extdiff'
'extdiff' is provided by the following extension:
extdiff  command to allow external programs to compare revisions
use "hg help extensions" for information on enabling extensions

(even though it is in .hgrc)


Solution

  • Please note that merge-tool and external diff are different tools for different tasks. For example you can use fmdiff script to use FileMerge for diff and k3diff for merge-tool:

    Your .hgrc should be:

    [extensions]
    # enable external diff program
    extdiff =
    
    [extdiff]
    cmd.opendiff = fmdiff
    opts.opendiff =
    
    [merge-tools]
    # Override stock tool location
    kdiff3.executable = /Applications/kdiff3.app/Contents/MacOS/kdiff3
    # Specify command line
    kdiff3.args = $base $local $other -o $output
    # Give higher priority
    kdiff3.priority = 1
    

    Now you can use

    hg opendiff myfile.ext
    

    Please note that 'opendiff' is a custom wrapper name, so you can change it to your likes but it cannot be one of already reserver names.