
How to use GVim diff mode as the diff viewer for svn
has been a research task for me for a long time.
Today, finally, I got a chance to devote some time
to set it up once and for all. On Windows, I use
two svn client. The GUI Tortoise svn client, and the
command line CollabNet client.
For the GUI client, it is quite easy to set up. Fire up the Tortoise svn
settings diaglog. Change the Diff Viewer setting to where your Windows GVim exe
is. Put the command line swith '-d' following the exe location. That is it.
Mine is like this:
C:\Program Files\Vim\vim72\gvim.exe -s "C:\Program Files\Vim\vimfiles\scripts\vimdiffSize.vim" -d %base %mine
Why I have another '-s' swith with argument? That's because
I want the diff window to be big and the two diff window split
equally. There may be other ways to do it. But mine way is giving
a vim command script to do it. The content of the command script
is like this:
:winsize 300 100^M
^W=
The '^M' and '^W' is one character, Control-M and Control-W. How to
enter it? In Vim type: Ctrl-V Ctrl-M and Ctrl-V Ctrl-W.
How about on the command line. svn has a config file. On Windows
it is in: c:\Documents and Settings\$UserName\Application Data\Subversion\config.
In this config file you can specify the option for diff-cmd,
which is equivalent to the --diff-cmd swith for 'svn diff' command.
The argument for this option need to be a Windows executable. So
you need a bat file to wrap you GVim exe. My diff-cmd option
setting is like this:
diff-cmd = "c:\msys\1.0\home\khong\bin\svndiff.bat"
The content of the svndiff.bat file is as following:
@ECHO OFF
REM Configure your favorite diff program here.
SET DIFF="C:\msys\1.0\opt\GVimPortable\gvim.exe"
REM Subversion provides the paths we need as the last two parameters.
REM These are parameters 6 and 7 (unless you use svn diff -x, in
REM which case, all bets are off).
SET LEFT=%6
SET RIGHT=%7
REM Call the diff command (change the following line to make sense for
REM your diff program).
%DIFF% -s c:\msys\1.0\home\khong\.vim\scripts\vimdiffSize.vim -d %LEFT% %RIGHT%
REM Return an errorcode of 0 if no differences were detected, 1 if some were.
REM Any other errorcode will be treated as fatal.
I am not the author. I got it from the (I think) svn official site.
The original name is svnwrap.bat.
Anyway, now I can use GVim diff mode to view diffs from svn.
No comments:
Post a Comment