Configure P4merge as my SVN diff tool on OSX

1.1k Views Asked by At

I want to use P4merge as my external diff tool for files in SVN when comparing local to unchanged. I just spent several hours on this when I should have been coding.

What do I need to do on OSX platform?

2

There are 2 best solutions below

0
On

Picking up on Stefan's answer, you can check what the parameters are that svn passes through and then write the script to pick out the right ones. I'm on bash, so:

#! /bin/sh
left=$6
right=$7
/Applications/p4merge.app/Contents/MacOS/p4merge $left $right

# Uncomment this to see what svn passes as parameters
# for i in $(seq 1 11)
#   do echo $i : ${!i}
# done

0
On

This is kind of hacky and only replaces the diff tool, not the merge tool but here it goes:

Create a python script named p4merge-diff-cmd:

#!/usr/bin/env python

import sys
import os.path

P4MERGE = '/Applications/p4merge.app/Contents/Resources/launchp4merge'

p4merge_args= [P4MERGE]
for arg in sys.argv[1:]:
  if os.path.exists(arg):
    p4merge_args.append(os.path.abspath(arg))

os.execv(P4MERGE, p4merge_args)

and make it executable

chmod a+x p4merge-diff-cmd

Then, in your ~/.subversion/config file change the line

# diff-cmd = diff_program (diff, gdiff, etc.)

to

diff-cmd = /full/path/to/p4merge-diff-cmd

Now svn diff <file> should launch p4merge.