How do I make Subversion use a third-party diff tool?
Asked Answered
S

5

20

I need more than the default diff! I have recently purchased "Beyond Compare" and I'd like to integrate it with svn, so its launched when I type:

svn diff foo.c

How do I do this?

Seek answered 12/11, 2008 at 16:57 Comment(1)
The original question mentioned Linux. That should probably have been left in the title of the question.Crepuscule
C
25

From a Beyond Compare forum post:

/usr/bin/bcompare_svn:

#!/bin/bash
/usr/bin/bcompare $6 $7 &
exit 0

The invocation of bcompare is obvious but I had to add "exit 0" so that svn would open more than one file at a time.

To make svn invoke my script, I added the following line in the [helpers] section in ~/.subversion/config

diff-cmd=/usr/bin/bcompare_svn
Crepuscule answered 12/11, 2008 at 17:19 Comment(0)
E
12

Look at svn --diff-cmd.

Egghead answered 12/11, 2008 at 16:59 Comment(2)
with --diff-cmd svn client (mine is 1.6.6) still generates -L options to the specified command, as in -L "file1 (rev xyz)" -L "file2 (rev abc)" So, unless your diff cmd is OK with those, it's broken. Chris has a good workaround in his Beyond Compare page, which involves creating a launcher script.Minta
I have the same problem as @Minta (12 years later!) with Diffmerge.Triplet
A
9

I'd like to add a comment to Andy Lester's answer but I don't have a big enough reputation. However, I can answer the question, I guess.

Anyways... as Andy already noted run "svn help diff" but to just give you the answer...

svn diff --diff-cmd <diff-cmd> --extensions <diff-cmd options>

svn diff --diff-cmd /usr/bin/diff --extensions "-bca" <filename(s)>

Alanis answered 12/11, 2008 at 20:49 Comment(0)
G
4

I recently added instructions for Subversion on Linux to our Using Beyond Compare With Version Control Systems web page. Once you follow the steps at the above link it should launch Beyond Compare 3 for Linux when you run "svn diff".

Gabriellagabrielle answered 10/12, 2008 at 23:56 Comment(0)
D
4

In latest Subversion, the script /usr/bin/bcompare_svn should be like this:

#!/bin/bash
cp $6 $6.save
cp $7 $7.save
{
    /usr/bin/bcompare $6.save $7.save 
    rm $6.save $7.save
} &
exit 0

or (untested code)

#!/bin/bash
base=`echo $3 | sed -r "s/^([^\(]+)[ \t]+\((.+)\)$/\1.\2/g" | xargs -i% basename "%"`
current=`echo $5 | sed -r "s/^([^\(]+)[ \t]\((.+)\)$/\1.\2/g" | xargs -i% basename "%"`

mv "$6" "/tmp/$base"
mv "$7" "/tmp/$current"
{
    /usr/local/bcompare/bin/bcompare "/tmp/$base" "/tmp/$current"
    rm "/tmp/$base" "/tmp/$current"
} &
exit 0
Dietsche answered 10/1, 2013 at 1:47 Comment(2)
Why should it be done like that? Any explanation for why you recommend this different script to the accepted answer, please?Nicki
On my cygwin machine, $6 and $7 don't exist in /tmp. StrangeTriplet

© 2022 - 2024 — McMap. All rights reserved.