1

I'm running Mercurial from the command line on Windows XP. I've got the extdiff plugin. I wanted

hg vimdiff

to use Vim's DirDiff command. I've tried putting

cmd.vimdiff = gvim
opts.vimdiff = -f '+next' '+execute "DirDiff" argv(0) argv(1)'

In my Mercurial.ini. If I do hg vimdiff then gvim opens with a file name '+next'. I think the problem is to do with quoting and pathnames specific to windows. I've tried a number of permutations of backslashes and single and double quotes (not entirely randomly) but with no luck.

I've solved my problem for now by making a separate script to invoke gvim i.e.

[extdiff]
cmd.vimdiff = c:\python25\python.exe
opts.vimdiff = c:\test\gvimdiff.py

and gvimdiff.py being

import sys
import os

os.system('gvim -c "DirDiff %s %s"' % (sys.argv[1],sys.argv[2]))

But if anyone knows the secret incantation to make it work direct from the command line let me know and I'll maybe try and get the documentation updated.

2
  • The accepted answer links to a blogger account that is private and the answer is no longer visible. Would you mind posting the solution?
    – Ken Smith
    Feb 5, 2015 at 23:17
  • @KenSmith I added an answer below: superuser.com/a/1638130/95874 Mar 30, 2021 at 9:41

2 Answers 2

1

The problem is caused by a sort of bug of vim when calling a function with f-args and the args are strings ending with '\'. The solution is to remove the trailing '\' for each arg.

I have a more compact solution here:

Using vimdiff with mercurial

0
0

For Windows, set opts.vimdiff in your .hgrc file like this:

opts.vimdiff=-f "+next" "+execute 'DirDiff' fnameescape(substitute(argv(0), '\\$', '', '')) fnameescape(substitute(argv(1), '\\$', '', ''))"

If you still run into an issue after the above fix and get an error message "There is no diff at the current line!", you are most likely using a newer version of DirDiff which forces UNIX-style locale specification at the command line without checking if it's running on Windows. The fix is to add the following line to your _vimrc or .vimrc file:

let g:DirDiffForceLang=""

Details here: https://vijay.tech/talks/mercurial-diffs-with-vim-on-windows/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .