Skip to content

Instantly share code, notes, and snippets.

@durin42
Created January 30, 2009 02:45
Show Gist options
  • Save durin42/54913 to your computer and use it in GitHub Desktop.
Save durin42/54913 to your computer and use it in GitHub Desktop.
from svn import core
from svn import client
import os
import sys
old, new = 0,1
os.system('mkdir example')
os.chdir('example')
url = 'file://%s/repo' % os.getcwd()
os.system('svnadmin create repo')
os.system('svn co %s wc' % url)
os.chdir('wc')
os.system('echo alpha > alpha')
os.system('svn add alpha')
os.system('svn ci -m "commit alpha"')
os.chdir('..')
os.system('svn diff %s -r %s:%s > expected-out' % (url, old, new))
out = open('example-out', 'w')
err = open('example-err', 'w')
def optrev(revnum):
optrev = core.svn_opt_revision_t()
optrev.kind = core.svn_opt_revision_number
optrev.value.number = revnum
return optrev
def _create_auth_baton(pool):
"""Create a Subversion authentication baton. """
providers = [
client.get_simple_provider(),
client.get_username_provider(),
client.get_ssl_client_cert_file_provider(),
client.get_ssl_client_cert_pw_file_provider(),
client.get_ssl_server_trust_file_provider(),
]
return core.svn_auth_open(providers, pool)
svn_config = core.svn_config_get_config(None)
pool = core.Pool()
client_context = client.create_context()
auth_baton = _create_auth_baton(pool)
client_context.auth_baton = auth_baton
client_context.config = svn_config
client.diff3([], url, optrev(old), url, optrev(new), True, True,
True, False, 'UTF-8', out, err, client_context, pool)
print 'example-out and expected-out should be identical'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment