Changes between Version 3 and Version 4 of Programming/Python/MercurialDiffsWithVimOnWindows

Jan 17, 2017, 8:21:08 AM (4 years ago)
Vijay Varadan

Added update to fix incorrect locale usage on Windows for newer DirDiff versions.


  • Programming/Python/MercurialDiffsWithVimOnWindows

    v3 v4  
    44[[Image(htdocs:images/mercurial/using-vim-with-mercurial-for-diffs.png, alt="vim + mercurial", align=center)]]
     6**[#UPDATE-2017-Jan-17 UPDATED 2017-Jan-17] for newer versions of !DirDiff.**
    68I had the devil of a time getting vimdiff and mercurial to play nicely with with each other on Windows for visual diffs. It worked great on posix systems using instructions from the mercurial wiki both to diff single files as well as a multiple files. But on Windows, it would only work for single files, giving me rather strange errors when trying to diff multiple files.
    4345The simple solution to the problem was to remove the trailing backslash if it was present. The easiest way to do that is to use the vim built-in function substitute. This function is the same one that is invoked within the editor when you do a find-replace. So, I modified the arguments passed to vimdiff as shown below and things were hunky dory.
    44 `opts.vdiff=-f "+next" "+execute "DirDiff" fnameescape(substitute(argv(0), '$', '', '')) fnameescape(substitute(argv(1), '$', '', ''))"`
     47opts.vdiff=-f "+next" "+execute 'DirDiff' fnameescape(substitute(argv(0), '\\$', '', '')) fnameescape(substitute(argv(1), '\\$', '', ''))"`
     50**[#UPDATE-2017-Jan-17 UPDATE 2017-Jan-17]**: 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:
     52let g:DirDiffForceLang=""
    4656=== Mixing MSYS and ''native'' Windows vim ===