dicroce
dicroce

Reputation: 46780

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

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?

Upvotes: 20

Views: 21999

Answers (5)

David Wu
David Wu

Reputation: 41

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

Upvotes: 4

Chris
Chris

Reputation: 41

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".

Upvotes: 4

shank
shank

Reputation: 484

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)>

Upvotes: 9

Ned Batchelder
Ned Batchelder

Reputation: 375594

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

Upvotes: 25

Andy Lester
Andy Lester

Reputation: 93676

Look at svn --diff-cmd.

Upvotes: 12

Related Questions