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?

Dan
  • 5,929
  • 6
  • 42
  • 52
dicroce
  • 45,396
  • 28
  • 101
  • 140

5 Answers5

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
Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
12

Look at svn --diff-cmd.

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
  • 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. – greggo Jan 24 '12 at 16:56
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)>

shank
  • 484
  • 2
  • 5
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
David Wu
  • 41
  • 2
  • Why should it be done like that? Any explanation for why you recommend this different script to the accepted answer, please? – Stewart Jan 06 '20 at 00:49
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".

Chris
  • 41
  • 2