Rev 1248: Add wrapper for client functions. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4
Jelmer Vernooij
jelmer at samba.org
Sat Jun 21 19:44:43 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.4
------------------------------------------------------------
revno: 1248
revision-id: jelmer at samba.org-20080621184441-ozpi37mrafqqnh0w
parent: jelmer at samba.org-20080621164258-fpce4algapj5xzmv
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-06-21 20:44:41 +0200
message:
Add wrapper for client functions.
added:
client.py client.py-20080621184436-8i1d6dfhzp8xi9mq-1
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
tests/__init__.py __init__.py-20060508151940-e9f4d914801a2535
workingtree.py workingtree.py-20060306120941-b083cb0fdd4a69de
=== modified file 'branch.py'
--- a/branch.py 2008-06-16 17:04:17 +0000
+++ b/branch.py 2008-06-21 18:44:41 +0000
@@ -24,16 +24,16 @@
from bzrlib.revision import is_null, ensure_null, NULL_REVISION
from bzrlib.workingtree import WorkingTree
-import svn.client, svn.core
+import svn.core
from bzrlib.plugins.svn import core
+from bzrlib.plugins.svn.client import Client
from bzrlib.plugins.svn.commit import push
from bzrlib.plugins.svn.config import BranchConfig
from bzrlib.plugins.svn.core import SubversionException
from bzrlib.plugins.svn.errors import NotSvnBranchPath, ERR_FS_NO_SUCH_REVISION
from bzrlib.plugins.svn.format import get_rich_root_format
from bzrlib.plugins.svn.repository import SvnRepository
-from bzrlib.plugins.svn.ra import create_svn_client
from bzrlib.plugins.svn.transport import bzr_to_svn_url
@@ -188,9 +188,8 @@
rev.value.number = revnum
svn_url = bzr_to_svn_url(self.base)
- client_ctx = create_svn_client(svn_url)
- svn.client.checkout(svn_url, to_location, rev,
- True, client_ctx)
+ client_ctx = Client(svn_url)
+ client_ctx.checkout(svn_url, to_location, rev, True)
return WorkingTree.open(to_location)
=== added file 'client.py'
--- a/client.py 1970-01-01 00:00:00 +0000
+++ b/client.py 2008-06-21 18:44:41 +0000
@@ -0,0 +1,62 @@
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from bzrlib.plugins.svn.ra import create_svn_client
+
+import svn.client
+
+class Client:
+ def __init__(self, url=None):
+ if url is not None:
+ self.client_ctx = create_svn_client(url)
+ else:
+ self.client_ctx = svn.client.create_context()
+ self.client_ctx.config = svn.core.svn_config_get_config(None)
+ self.client_ctx.log_msg_func2 = \
+ svn.client.svn_swig_py_get_commit_log_func
+
+ def update(self, basedir, revision, recurse=True):
+ return svn.client.update(basedir, revision, recurse, self.client_ctx)
+
+ def checkout(self, url, path, revision, recurse=True):
+ return svn.client.checkout(url, path, revision, recurse, self.client_ctx)
+
+ def commit(self, targets, recursive=True, keep_locks=False):
+ return svn.client.commit2(targets, recursive, keep_locks, self.client_ctx)
+
+ def propset(self, name, value, path, recurse=True, skip_checks=False):
+ return svn.client.propset2(name, value, path, recurse, skip_checks, self.client_ctx)
+
+ def propget(self, name, path, rev, recurse=True):
+ return svn.client.propget(name, path, rev, recurse, self.client_ctx)
+
+ def revprop_get(self, name, url, rev):
+ return svn.client.revprop_get(name, url, rev, self.client_ctx)
+
+ def revprop_set(self, name, value, url, rev, force=False):
+ return svn.client.revprop_set(name, value, url, rev, force, self.client_ctx)
+
+ def add(self, relpath, recursive, force=False, noignore=False):
+ return svn.client.add3(relpath, recursive, force, noignore, self.client_ctx)
+
+ def delete(self, relpaths, force=False):
+ return svn.client.delete2(relpaths, force, self.client_ctx)
+
+ def copy(self, oldpath, rev, newpath):
+ return svn.client.copy2(oldpath, rev, newpath, self.client_ctx)
+
+ def log(self, targets, start, end, discover_changed_paths, strict_node_history, rcvr):
+ return svn.client.log(targets, start, end, discover_changed_paths, strict_node_history,
+ rcvr, self.client_ctx)
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2008-06-21 16:21:46 +0000
+++ b/tests/__init__.py 2008-06-21 18:44:41 +0000
@@ -30,7 +30,9 @@
from bzrlib.workingtree import WorkingTree
import svn.core
+
from bzrlib.plugins.svn import repos
+from bzrlib.plugins.svn.client import Client
from bzrlib.plugins.svn.ra import RemoteAccess
class TestCaseWithSubversionRepository(TestCaseInTempDir):
@@ -39,9 +41,8 @@
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()
+ self.client_ctx.client_ctx.log_msg_baton2 = self.log_message_func
def log_message_func(self, items, pool):
return self.next_message
@@ -90,9 +91,7 @@
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, rev)
@staticmethod
def create_checkout(branch, path, revision_id=None, lightweight=False):
@@ -114,7 +113,7 @@
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()
@@ -124,8 +123,7 @@
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)
+ ret = self.client_ctx.propget(name, path, rev, recursive)
if recursive:
return ret
else:
@@ -135,13 +133,13 @@
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, rev)[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)
+ self.client_ctx.revprop_set(name, value, url, rev, True)
def client_commit(self, dir, message=None, recursive=True):
"""Commit current changes in specified working copy.
@@ -151,7 +149,7 @@
olddir = os.path.abspath('.')
self.next_message = message
os.chdir(dir)
- info = svn.client.commit2(["."], recursive, False, self.client_ctx)
+ info = self.client_ctx.commit(["."], recursive, False)
os.chdir(olddir)
assert info is not None
return (info.revision, info.date, info.author)
@@ -161,7 +159,7 @@
: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()
@@ -178,12 +176,9 @@
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.client_ctx.log([path], self.revnum_to_opt_rev(start_revnum),
self.revnum_to_opt_rev(stop_revnum),
- True,
- True,
- rcvr,
- self.client_ctx)
+ True, True, rcvr)
return ret
def client_delete(self, relpath):
@@ -191,7 +186,7 @@
: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.
@@ -205,12 +200,12 @@
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, rev, newpath)
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, rev, True)
def build_tree(self, files):
"""Create a directory tree.
=== modified file 'workingtree.py'
--- a/workingtree.py 2008-06-19 15:33:26 +0000
+++ b/workingtree.py 2008-06-21 18:44:41 +0000
@@ -40,7 +40,6 @@
from bzrlib.plugins.svn.mapping import (SVN_PROP_BZR_ANCESTRY, SVN_PROP_BZR_FILEIDS,
SVN_PROP_BZR_REVISION_ID, SVN_PROP_BZR_REVISION_INFO,
escape_svn_path, generate_revision_metadata)
-from bzrlib.plugins.svn.ra import create_svn_client
from bzrlib.plugins.svn.remote import SvnRemoteAccess
from bzrlib.plugins.svn.repository import SvnRepository
from bzrlib.plugins.svn.svk import SVN_PROP_SVK_MERGE, parse_svk_features, serialize_svk_features
@@ -54,6 +53,7 @@
import svn.core
+from bzrlib.plugins.svn.client import Client
from bzrlib.plugins.svn.format import get_rich_root_format
def generate_ignore_list(ignore_map):
@@ -80,9 +80,7 @@
self.bzrdir = bzrdir
self._branch = branch
self.base_revnum = 0
- self.client_ctx = create_svn_client(bzrdir.svn_url)
- self.client_ctx.log_msg_func2 = \
- svn.client.svn_swig_py_get_commit_log_func
+ self.client_ctx = Client(bzrdir.svn_url)
self._get_wc()
max_rev = revision_status(self.basedir, None, True)[1]
@@ -148,7 +146,7 @@
def update(self, change_reporter=None):
rev = svn.core.svn_opt_revision_t()
rev.kind = svn.core.svn_opt_revision_head
- svn.client.update(self.basedir, rev, True, self.client_ctx)
+ self.client_ctx.update(self.basedir, rev, True)
def remove(self, files, verbose=False, to_file=None):
# FIXME: Use to_file argument
@@ -430,7 +428,7 @@
""" Simple log message provider for unit tests. """
return message.encode("utf-8")
- self.client_ctx.log_msg_baton2 = log_message_func
+ self.client_ctx.client_ctx.log_msg_baton2 = log_message_func
if rev_id is not None:
extra = "%d %s\n" % (self.branch.revno()+1, rev_id)
else:
@@ -451,8 +449,7 @@
try:
try:
- commit_info = svn.client.commit3(specific_files, True, False,
- self.client_ctx)
+ commit_info = self.client_ctx.commit(specific_files, True, False)
except SubversionException, (_, num):
if num == ERR_FS_TXN_OUT_OF_DATE:
raise OutOfDateTree(self)
@@ -470,7 +467,7 @@
wc.close()
raise
- self.client_ctx.log_msg_baton2 = None
+ self.client_ctx.client_ctx.log_msg_baton2 = None
revid = self.branch.generate_revision_id(commit_info.revision)
@@ -566,7 +563,7 @@
rev = svn.core.svn_opt_revision_t()
rev.kind = svn.core.svn_opt_revision_number
rev.value.number = self.branch.lookup_revision_id(stop_revision)
- fetched = svn.client.update(self.basedir, rev, True, self.client_ctx)
+ fetched = self.client_ctx.update(self.basedir, rev, True)
self.base_revid = self.branch.generate_revision_id(fetched)
result.new_revid = self.base_revid
result.new_revno = self.branch.revision_id_to_revno(result.new_revid)
More information about the bazaar-commits
mailing list