Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default SVN diffing tool

Tags:

diff

svn

Following a blog, I created a batch file, wm.bat:

"d:\svnroot\external\winmerge\WinMerge.exe" /B /WAIT "d:\svnroot\external\winmerge\WinMergeU.exe" /e /ub /dl %3 /dr %5 %6 %7

And I tried calling

svn diff | wm

but that didn't work. So how do I integrate WinMerge or similar utility with svn diff?

Extending on David's answer below, changing the default for Windows requires editing the configuration file located at (for Windows XP)

C:\Documents and Settings\%USERNAME%\Application Data\Subversion\config

or (Windows Vista)

C:\Users\%USERNAME%\AppData\Roaming\Subversion\config
like image 272
aleemb Avatar asked Feb 20 '09 11:02

aleemb


People also ask

How to check svn diff with previous version?

svn diff -r HEAD <item> if you want to get the difference between your working copy and the last committed revision. svn diff -r PREV:COMMITTED <item> if you want to see what the last commit did. You should take look at Revision Keywords.

How to check diff in svn?

If you want to see the differences between a file in your working copy, and a file in any Subversion repository, you can do that directly in explorer by selecting the file then holding down the Shift key whilst right clicking to obtain the context menu. Select TortoiseSVN → Diff with URL.

How do I diff two revisions in svn?

Pick the two revisions you want to compare then use Context Menu → Compare Revisions. If you want to compare the same item in two different trees, for example the trunk and a branch, you can use the repository browser to open up both trees, select the file in both places, then use Context Menu → Compare Revisions.


2 Answers

Ok, looking at the original blog post, this is what you want:

svn diff --diff-cmd wm [optional-filename]

If you want to see what is actually happening here (i.e. what sort of parameters the svn diff passes to the nominated diff-cmd), you can just use svn diff --diff-cmd echo and see what it says:

[~/src/gosmore-dev]$ svn diff --diff-cmd echo
Index: gosmore.cpp
===================================================================
-u -L gosmore.cpp   (revision 13753) -L gosmore.cpp (working copy) .svn/text-base/gosmore.cpp.svn-base gosmore.cpp

Some quotes were removed above, but basically you can see that svn diff will pass

-u -L "<left-label>" -L "<right-label>" <left-file> <right-file> 

to your batch file. The batch file you have is used to turn these commands into the format that WinMerge understands.

More details and examples on how this all works are provided in the svn book.

To make your batch file the default for svn diff, you need to add the following line in the [helpers] section in your local subversion config file (~/.subversion/config in Linux, I'm not sure where the config file is located in Windows) (see this earlier SO question)

diff-cmd=wm.bat
like image 185
David Dean Avatar answered Oct 20 '22 11:10

David Dean


Check out this link:

http://blog.tplus1.com/index.php/2007/08/29/how-to-use-vimdiff-as-the-subversion-diff-tool/

Here is a copy for SOer's convienience:

Get this diffwrap.sh script and save it anywhere. I saved mine in my $HOME/bin directory. Make sure to make it executable! I’m showing it below:

#!/bin/sh
# Configure your favorite diff program here.
DIFF="/usr/bin/vimdiff" 
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT="$6"
RIGHT="$7"
# Call the diff command (change the following line to make sense for
# your merge program).
"$DIFF" "$LEFT" "$RIGHT"

# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.

Then change your $HOME/.subversion/config file to point at that script:

[helpers]
diff-cmd = /home/matt/bin/diffwrap.sh

Then go diff a file!

like image 33
pierrotlefou Avatar answered Oct 20 '22 12:10

pierrotlefou