extdiff extension

extdiff extension#

command to allow external programs to compare revisions

The extdiff Mercurial extension allows you to use external programs to compare revisions, or revision with working directory. The external diff programs are called with a configurable set of options and two non-option arguments: paths to directories containing snapshots of files to compare.

If there is more than one file being compared and the "child" revision is the working directory, any modifications made in the external diff program will be copied back to the working directory from the temporary directory.

The extdiff extension also allows you to configure new diff commands, so you do not need to type `hg extdiff -p kdiff3` always.

[extdiff]
# add new command that runs GNU diff(1) in 'context diff' mode
cdiff = gdiff -Nprc5
## or the old way:
#cmd.cdiff = gdiff
#opts.cdiff = -Nprc5

# add new command called meld, runs meld (no need to name twice).  If
# the meld executable is not available, the meld tool in [merge-tools]
# will be used, if available
meld =

# add new command called vimdiff, runs gvimdiff with DirDiff plugin
# (see http://www.vim.org/scripts/script.php?script_id=102) Non
# English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
# your .vimrc
vimdiff = gvim -f "+next" \
          "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"

Tool arguments can include variables that are expanded at runtime:

$parent1, $plabel1 - filename, descriptive label of first parent
$child,   $clabel  - filename, descriptive label of child revision
$parent2, $plabel2 - filename, descriptive label of second parent
$root              - repository root
$parent is an alias for $parent1.

The extdiff extension will look in your [diff-tools] and [merge-tools] sections for diff tool arguments, when none are specified in [extdiff].

[extdiff]
kdiff3 =

[diff-tools]
kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child

If a program has a graphical interface, it might be interesting to tell Mercurial about it. It will prevent the program from being mistakenly used in a terminal-only environment (such as an SSH terminal session), and will make `hg extdiff --per-file` open multiple file diffs at once instead of one by one (if you still want to open file diffs one by one, you can use the --confirm option).

Declaring that a tool has a graphical interface can be done with the gui flag next to where diffargs are specified:

[diff-tools]
kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
kdiff3.gui = true

You can use -I/-X and list of file or directory names like normal `hg diff` command. The extdiff extension makes snapshots of only needed files, so running the external diff program will actually be pretty fast (at least faster than having to compare the entire tree).

Commands

  • extdiff: use external program to diff repository (or selected files)