Last active
August 29, 2015 14:01
-
-
Save user454322/4a08b9c106d6c7b4b598 to your computer and use it in GitHub Desktop.
This is a simple wrapper intended for use with the --diff-cmd argument of 'svn diff'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Forked from: | |
# https://github.com/c4rlo/Subversion-scripts/blob/master/svndiff_helper | |
# | |
# The easiest way to use this script is by setting | |
# diff-cmd = svndiff_helper | |
# in section [helpers] in your ~/.subversion/config. | |
import sys, re, subprocess, os, os.path | |
n1, n2 = sys.argv[3], sys.argv[5] | |
f1, f2 = sys.argv[6], sys.argv[7] | |
def lntemp(f, n): | |
fn = n.split('\t')[0] | |
ext = os.path.splitext(fn)[1] | |
if ext not in ("", os.path.splitext(f)[1]): | |
tmpfn = f + ext | |
os.symlink(os.path.basename(f), tmpfn) | |
return tmpfn | |
else: return f | |
lf1 = lntemp(f1, n1) | |
lf2 = lntemp(f2, n2) | |
def sanitise(n): | |
n = re.sub(r'\s+', r'\ ', n) | |
n = re.sub(r'/', r'\\\\', n) | |
return n | |
vim_rc = subprocess.call(['vim', '-df', | |
'--cmd', "au BufReadPost " + lf2 + "silent f " + sanitise(lf2), | |
'--cmd', "au BufReadPost " + lf1 + "silent f " + sanitise(n1), | |
lf2, lf1]) | |
if lf1 != f1: os.remove(lf1) | |
if lf2 != f2: os.remove(lf2) | |
sys.exit(vim_rc) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment