46
53
# Attempt to get the diff for these revisons
48
svnclient = pysvn.Client()
55
svnclient = ivle.svn.create_auth_svn_client(username=ivle.conf.login,
56
password=ivle.conf.svn_pass)
49
57
svnclient.exception_style = 1
50
58
diff = svnclient.diff
51
diff_text = diff( '/tmp/svndiff',
60
# pysvn's diff tempfile behaviour changes with Subversion 1.6.x.
61
# < 1.6 wants a filename, >= 1.6 wants a directory.
62
if pysvn.svn_version > (1, 6):
65
tmp_path = '/tmp/svndiff'
67
diff_text = diff(tmp_path,
52
68
os.path.join('/home', sys.argv[1]),
56
print cjson.encode({'diff': diff_text})
72
print json.dumps({'diff': diff_text.decode('utf-8')})
57
73
except pysvn.ClientError, e:
62
78
# See subversion/include/svn_error_codes.h.
79
# 150000: ERR_ENTRY_NOT_FOUND
63
80
# 155007: WC_NOT_DIRECTORY.
64
81
# 160013: FS_NOT_FOUND
65
82
# 200005: UNVERSIONED_RESOURCE
66
if code in (155007, 160013, 200005):
83
if code in (150000, 155007, 160013, 200005):
69
86
error = '%s (code %d)' % (error, code)
73
print cjson.encode({'error': error})
90
print json.dumps({'error': error})