from bzrlib.bzrdir import BzrDir
from bzrlib.tests import TestCaseInTempDir, TestSkipped
from bzrlib.trace import mutter
-from bzrlib.urlutils import local_path_to_url
from bzrlib.workingtree import WorkingTree
-import svn.core, svn.repos
-from bzrlib.plugins.svn.ra import RemoteAccess
+from bzrlib.plugins.svn import repos, wc, client, ra, properties
+from bzrlib.plugins.svn.ra import RemoteAccess, txdelta_send_stream
class TestCaseWithSubversionRepository(TestCaseInTempDir):
"""A test case that provides the ability to build Subversion
def setUp(self):
super(TestCaseWithSubversionRepository, self).setUp()
- self.client_ctx = svn.client.create_context()
- self.client_ctx.log_msg_func2 = svn.client.svn_swig_py_get_commit_log_func
- self.client_ctx.log_msg_baton2 = self.log_message_func
+ self.client_ctx = client.Client()
+ self.client_ctx.log_msg_func = self.log_message_func
- def log_message_func(self, items, pool):
- return self.next_message
+ def log_message_func(self, items):
+ return (self.next_message, None)
def make_repository(self, relpath, allow_revprop_changes=True):
"""Create a repository.
"""
abspath = os.path.join(self.test_dir, relpath)
- svn.repos.create(abspath, '', '', None, None)
+ repos.create(abspath)
if allow_revprop_changes:
if sys.platform == 'win32':
open(revprop_hook, 'w').write("#!/bin/sh\n")
os.chmod(revprop_hook, os.stat(revprop_hook).st_mode | 0111)
- return local_path_to_url(abspath)
+ return urlutils.local_path_to_url(abspath)
def make_remote_bzrdir(self, relpath):
"""Create a repository."""
return self.open_local_bzrdir(repos_url, relpath)
def make_checkout(self, repos_url, relpath):
- rev = svn.core.svn_opt_revision_t()
- rev.kind = svn.core.svn_opt_revision_head
-
- svn.client.checkout2(repos_url, relpath,
- rev, rev, True, False, self.client_ctx)
+ self.client_ctx.checkout(repos_url, relpath, "HEAD", "HEAD",
+ True, False)
@staticmethod
def create_checkout(branch, path, revision_id=None, lightweight=False):
def client_set_prop(self, path, name, value):
if value is None:
value = ""
- svn.client.propset2(name, value, path, False, True, self.client_ctx)
+ self.client_ctx.propset(name, value, path, False, True)
def client_get_prop(self, path, name, revnum=None, recursive=False):
- rev = svn.core.svn_opt_revision_t()
-
if revnum is None:
- rev.kind = svn.core.svn_opt_revision_working
- else:
- rev.kind = svn.core.svn_opt_revision_number
- rev.value.number = revnum
- ret = svn.client.propget2(name, path, rev, rev, recursive,
- self.client_ctx)
+ revnum = "WORKING"
+ ret = self.client_ctx.propget(name, path, revnum, revnum, recursive)
if recursive:
return ret
else:
return ret.values()[0]
def client_get_revprop(self, url, revnum, name):
- rev = svn.core.svn_opt_revision_t()
- rev.kind = svn.core.svn_opt_revision_number
- rev.value.number = revnum
- return svn.client.revprop_get(name, url, rev, self.client_ctx)[0]
+ return self.client_ctx.revprop_get(name, url, revnum)[0]
def client_set_revprop(self, url, revnum, name, value):
- rev = svn.core.svn_opt_revision_t()
- rev.kind = svn.core.svn_opt_revision_number
- rev.value.number = revnum
- svn.client.revprop_set(name, value, url, rev, True, self.client_ctx)
+ return self.client_ctx.revprop_set(name, value, url, revnum)
def client_commit(self, dir, message=None, recursive=True):
"""Commit current changes in specified working copy.
"""
olddir = os.path.abspath('.')
self.next_message = message
- os.chdir(dir)
- info = svn.client.commit2(["."], recursive, False, self.client_ctx)
- os.chdir(olddir)
+ info = self.client_ctx.commit([dir], recursive, False)
assert info is not None
- return (info.revision, info.date, info.author)
+ return info
def client_add(self, relpath, recursive=True):
"""Add specified files to working copy.
:param relpath: Path to the files to add.
"""
- svn.client.add3(relpath, recursive, False, False, self.client_ctx)
+ self.client_ctx.add(relpath, recursive, False, False)
- def revnum_to_opt_rev(self, revnum):
- rev = svn.core.svn_opt_revision_t()
- if revnum is None:
- rev.kind = svn.core.svn_opt_revision_head
- else:
- assert isinstance(revnum, int)
- rev.kind = svn.core.svn_opt_revision_number
- rev.value.number = revnum
- return rev
-
- def client_log(self, path, start_revnum=None, stop_revnum=None):
- assert isinstance(path, str)
+ def client_log(self, url, start_revnum=0, stop_revnum=-1):
+ ra = RemoteAccess(url.encode("utf-8"))
ret = {}
- def rcvr(orig_paths, rev, author, date, message, pool):
- ret[rev] = (orig_paths, author, date, message)
- svn.client.log([path], self.revnum_to_opt_rev(start_revnum),
- self.revnum_to_opt_rev(stop_revnum),
- True,
- True,
- rcvr,
- self.client_ctx)
+ def rcvr(orig_paths, rev, revprops):
+ ret[rev] = (orig_paths,
+ revprops.get(properties.PROP_REVISION_AUTHOR),
+ revprops.get(properties.PROP_REVISION_DATE),
+ revprops.get(properties.PROP_REVISION_LOG))
+ if stop_revnum == -1:
+ stop_revnum = ra.get_latest_revnum()
+ ra.get_log(rcvr, None, start_revnum, stop_revnum, 0, True, True)
return ret
def client_delete(self, relpath):
:param relpath: Path to the files to remove.
"""
- svn.client.delete2([relpath], True, self.client_ctx)
+ self.client_ctx.delete([relpath], True)
def client_copy(self, oldpath, newpath, revnum=None):
"""Copy file in working copy.
:param oldpath: Relative path to original file.
:param newpath: Relative path to new file.
"""
- rev = svn.core.svn_opt_revision_t()
- if revnum is None:
- rev.kind = svn.core.svn_opt_revision_head
- else:
- rev.kind = svn.core.svn_opt_revision_number
- rev.value.number = revnum
- svn.client.copy2(oldpath, rev, newpath, self.client_ctx)
+ self.client_ctx.copy(oldpath, newpath, revnum)
def client_update(self, path):
- rev = svn.core.svn_opt_revision_t()
- rev.kind = svn.core.svn_opt_revision_head
- svn.client.update(path, rev, True, self.client_ctx)
+ self.client_ctx.update([path], None, True)
def build_tree(self, files):
"""Create a directory tree.
:return: FS.
"""
- repos = svn.repos.open(relpath)
-
- return svn.repos.fs(repos)
+ return repos.Repository(relpath).fs()
def commit_editor(self, url, message="Test commit"):
ra = RemoteAccess(url.encode('utf8'))
else:
child_baton = dir_baton.open_file(subpath)
if isinstance(contents, str):
- (txdelta, txbaton) = child_baton.apply_textdelta()
- svn.delta.svn_txdelta_send_stream(StringIO(contents), txdelta, txbaton)
+ txdelta = child_baton.apply_textdelta(None)
+ txdelta_send_stream(StringIO(contents), txdelta)
if subpath in self.props:
for k, v in self.props[subpath].items():
child_baton.change_prop(k, v)
'test_branchprops',
'test_changes',
'test_checkout',
+ 'test_client',
+ 'test_core',
'test_commit',
'test_config',
'test_convert',
'test_logwalker',
'test_mapping',
'test_push',
+ 'test_ra',
'test_radir',
'test_repos',
+ 'test_repository',
'test_revids',
'test_revspec',
'test_scheme',
'test_transport',
'test_tree',
'test_upgrade',
+ 'test_wc',
'test_workingtree',
'test_blackbox']
suite.addTest(loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i) for i in testmod_names]))