Blog | Admin | Archives | Heatmap | Recent | Random | Plan
    • Instagram Image
    • Visited my Mecca.
    • Instagram Image
    • Red Lentil Chorizo Soup

Make mercurial use vimdiff the same way git does

At work, one of my favorite pastimes is getting mercurial to behave more like git.

Today, I decided to tackle merge conflict resolution using vimdiff.

Git has great support for this. In my .gitconfig, I have the following lines:

tool = vimdiff

Git is smart enough to run vimdiff with four panes — base, local, remote, and output. The first three windows are at the top, and the output window is at the bottom. Since it’s vimdiff, everything is colorized so you know what is happening, and the output has all the merge markers so you know what you need to fix.

Mercurial’s default seems to be a three-pane vimdiff view that has local, other, and base with no fourth pane to do the editing. This is, in my opinion, strictly worse.

I thought it would be straightforward, but I was wrong since the official documentation is wrong in a few ways (I may edit it, since it’s a wiki, if it’s easy, after I finish this post).

What I ended up with that actually works (using hg version 2.9.1 and vim 7.4) is adding the following to my .hgrc:

vimdiff.executable = vim
vimdiff.args = -d -c "wincmd J" $output $local $other $base
vimdiff.premerge = keep