63

Every time I do an hg diff file.ext I end up using a console diff application. I would like to use Kdiff3 or WinMerge (I'm using Windows).

Is there a way to change that? I can't find a reference in Mercurial documentation (I'm not talking about merge!).

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Tute
  • 6,943
  • 12
  • 51
  • 61

4 Answers4

71

I've solved this using a Mercurial built-in extension... I just have to add the following lines to Mercurial.ini (on Mercurial folder):

[extensions]
hgext.extdiff=

[extdiff]
cmd.vdiff = kdiff3

When I want to use kdiff3 instead of diff I only have to use:

hg vdiff file.ext
Tute
  • 6,943
  • 12
  • 51
  • 61
  • 2
    Also, you can pass options to the difftool, eg. `[extdiff] opts.vdiff = 2> /dev/null` – ACyclic Aug 07 '12 at 10:43
  • 2
    This answer (and the others below so far) makes another diff tool available, but does not change the "default diff tool." I.e., it doesn't change what tool is used when you call `hg diff` — or more importantly when you use `hg log -p` to look at a whole collection of changesets. I'd love to find a way to really change the default? (e.g., to be able to use a word-based diff sometimes when reviewing a branch.) – Joshua Goldberg Jan 03 '18 at 20:06
8

With this config

[extdiff]
cmd.kdiff3 =

I use this command to see diffs:

hg kdiff

This shows a directory tree with all files that have changed. You click a file to see diffs for just the file. You may be able to add a file parameter to the command to just see one file.

More info here.

Noumenon
  • 5,099
  • 4
  • 53
  • 73
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
5

If you are looking for something like git difftool, where you don't need to type the filenames and see the diff for all changed files, add these to your ~/.hgrc, and run hg difftool.

[extensions]
extdiff =

[extdiff]
cmd.vimdiff = vimdiff

[alias]
difftool = !for file in $(hg status -n); do hg vimdiff $file; done

or for windows:

[alias]
difftool = !FOR /f %F IN ('hg status -nmar') DO hg vimdiff %F
Community
  • 1
  • 1
musa
  • 1,050
  • 4
  • 15
  • 26
3

I just had this problem a few minutes ago; I just installed it and added its path (default is at c:\program files\kdiff3) to my system PATH e.v. Restarted my window to pick up the new path, and "hg kdiff3" just worked. As it turns out the following is in my base "mercurial.ini" file, this allows the kdiff3 to work for all hg repos on the system.

[extensions]  
hgext.extdiff =  

[extdiff]  
cmd.kdiff3 =

[merge-tools]  
kdiff3.args = $base $local $other -o $output
Oleg Abrazhaev
  • 2,751
  • 2
  • 28
  • 41
Ken
  • 369
  • 3
  • 15