How do I make Subversion use a third-party diff to

2019-03-17 22:04发布

问题:

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?

回答1:

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


回答2:

Look at svn --diff-cmd.



回答3:

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



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



回答5:

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