Side-by-side diffs for Mercurial (hg) & icdiff revisited
A while back I told you how to get side-by-side diffs in Mercurial using icdiff. Turns out the author of icdiff has added the
--recursive flag to make the tool accept directories and diff the contents of the files within. New setup instructions follow.
Same as before: Download and install icdiff, making sure
/usr/local/bin is in your
Next, lets configure Mercurial so that it knows about
icdiff. We'll also set the default pager for all commands to
less. Add the following to your
[extensions] extdiff= pager= [extdiff] cmd.icdiff=icdiff # extdiff passes two directories to the diff command # --recursive tells icdiff to treat the two params as directories # and recursively diff their contents. # -- line-numbers shows line numbers on both sides opts.icdiff=--recursive --line-numbers [pager] # Setting the variable LESS is like passing those options to less. # In this case, -F (quit if fits on screen), and -R (pass through control chars, # required for color output) pager = LESS='FR' less # Use pager for these commands only. Add any commands you use here. attend = icdiff,diff,status,log
You can now replace
diff in your Mercurial commands with
icdiff, and it will do a side-by-side diff instead of inline.
hg icdiff is of course too long, add the following aliases to your
# side-by-side diffs for uncommitted files alias ic='hg icdiff' # diff all changes since the base revision, including uncommitted # (from master if you are using bookmarks, for example) alias ica='hg icdiff -r .^' # diff the existing changes, excluding uncommitted alias ice='hg icdiff --ch .'