Next article: Fun With Beowulf Clusters
Previous article: Dashboard Rant
Tags: filemerge python subversion versioncontrol
I was introduced to subversion about a month and a half ago, and have generally found it to be wonderful, and a vast improvement over CVS. I won't get into the details, because I'll just sound like every other person out there who has switched to svn and then raved about it, so you can just look up somebody else's blog post on the subject. One thing I did miss, however, was the ability to open diffs in FileMerge.
Previously I got my FileMerge graphical diffs by using CVL, a GUI front-end to CVS, but I've been using svn on the command-line and am very happy with that, except for this one thing. I figured that this must be a common request, and that somebody has figured it out, so I went Googling. I turned up nothing good; a couple of gigantic scripts that didn't work on my computer, and nothing else.So finally today, I decided to solve things once and for all, and came up with 20 lines of python that fixes it up very nicely. And now I'll share it with the world!
Put the following code into a file called svnopendiffshim.py that's somewhere in your $PATH:
#!/usr/bin/python2
from sys import argv
from os import execlp
import re
left = "";
right = "";
argv.pop(0)
while argv:
arg = argv.pop(0)
if arg == "-u":
pass
elif arg == "-L":
argv.pop(0)
elif left == "":
left = arg
else:
right = arg
execlp("opendiff", "opendiff", left, right)
Now, add one line to your .profile (if you're using a shell other than bash, you're on your own here):
alias svndiff='svn diff --diff-cmd svnopendiffshim.py'
Now open a new Terminal window, go into a project, and type svndiff somefile.h
and, bang, your diff opens in FileMerge.
So there you have it. I hope somebody finds this as useful as I do.
Comments:
http://www.friday.com/bbum/2005/08/01/us..
$ chmod +x svnopendiffshiim
$ sudo cp svnopendiffshim /usr/bin
$ vi ~/.subversion/config
Add:
[helpers]
diff-cmd = svnopendiff
This much easier and does not require and difference in how you call svn diff nor will you need to mess with you enviroment settings.
$ svn diff
Thanks for the script.
Regards,
Brian
diff-cmd = svnopendiffshiim
Or whatever you name the script you put in /usr/bin. On that note, you do not need the .py extension. Also you may want to make the header on your python script ”#!/usr/bin/env python”.
http://ssel.vub.ac.be/ssel/internal:fmdi..
os.spawnlp(os.P_NOWAIT, "opendiff", "opendiff", left, right)
Index: css/debug.css
===================================================================
exec of 'svnopendiffshim.py' failed: No such file or directorysvn: 'svnopendiffshim.py' returned 255
Any thoughts?
Thanks anyways!
http://www.defraine.net/~brunod/fmdiff/
Same idea, but shell script based.
Comments RSS feed for this page
Add your thoughts, post a comment:
Spam and off-topic posts will be deleted without notice. Culprits may be publicly humiliated at my sole discretion.