Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure P4merge as my SVN diff tool on OSX

Tags:

macos

svn

p4merge

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?

like image 953
MedicineMan Avatar asked Jan 09 '15 10:01

MedicineMan


People also ask

Is p4merge still free?

Perforce, the company best known for its enterprise version control platform, also offers a solid diff tool: P4Merge is free of charge and comes with a basic feature set that makes it an interesting option on Windows, macOS and Linux.

What does p4 merge do?

P4Merge is a visual diff tool that displays the differences between file versions and helps you to resolve conflicts and merge competing versions into one.


1 Answers

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.

like image 55
Stefan Avatar answered Sep 19 '22 01:09

Stefan