Rev 1246: Add wrapper for svn.repos. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4
Jelmer Vernooij
jelmer at samba.org
Sat Jun 21 17:21:47 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.4
------------------------------------------------------------
revno: 1246
revision-id: jelmer at samba.org-20080621162146-wjwtgd6hijvoz406
parent: jelmer at samba.org-20080621160510-eehv5pu62512f9tv
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-06-21 18:21:46 +0200
message:
Add wrapper for svn.repos.
added:
repos.py repos.py-20080621160832-kvb89lus284oufuq-1
modified:
convert.py svn2bzr.py-20051018015439-cb4563bff29e632d
errors.py errors.py-20061226172623-w1sbj8ynpo0eojqp-1
fetch.py fetch.py-20060625004942-x2lfaib8ra707a8p-1
format.py format.py-20070917005147-94kb7zysotf82kqw-1
tests/__init__.py __init__.py-20060508151940-e9f4d914801a2535
=== modified file 'convert.py'
--- a/convert.py 2008-06-19 13:58:42 +0000
+++ b/convert.py 2008-06-21 16:21:46 +0000
@@ -23,11 +23,11 @@
from bzrlib.revision import ensure_null
from bzrlib.transport import get_transport
+from bzrlib.plugins.svn import repos
+from bzrlib.plugins.svn.core import SubversionException
from bzrlib.plugins.svn.errors import ERR_STREAM_MALFORMED_DATA
from bzrlib.plugins.svn.format import get_rich_root_format
-import svn.core, svn.repos
-from svn.core import SubversionException
def transport_makedirs(transport, location_url):
"""Create missing directories.
@@ -63,7 +63,7 @@
created.
"""
from cStringIO import StringIO
- repos = svn.repos.svn_repos_create(outputdir, '', '', None, None)
+ r = repos.create(outputdir)
if dumpfile.endswith(".gz"):
import gzip
file = gzip.GzipFile(dumpfile)
@@ -73,13 +73,12 @@
else:
file = open(dumpfile)
try:
- svn.repos.load_fs2(repos, file, StringIO(),
- svn.repos.load_uuid_default, '', 0, 0, None)
+ r.load_fs(file, StringIO(), repos.LOAD_UUID_DEFAULT)
except SubversionException, (_, num):
if num == ERR_STREAM_MALFORMED_DATA:
raise NotDumpFile(dumpfile)
raise
- return repos
+ return r
def convert_repository(source_repos, output_url, scheme=None, layout=None,
=== modified file 'errors.py'
--- a/errors.py 2008-06-19 15:33:26 +0000
+++ b/errors.py 2008-06-21 16:21:46 +0000
@@ -56,7 +56,6 @@
ERR_WC_UNSUPPORTED_FORMAT = 155021
-
class NotSvnBranchPath(NotBranchError):
"""Error raised when a path was specified that did not exist."""
_fmt = """%(path)s is not a valid Subversion branch path.
=== modified file 'fetch.py'
--- a/fetch.py 2008-06-19 14:06:37 +0000
+++ b/fetch.py 2008-06-21 16:21:46 +0000
@@ -429,6 +429,7 @@
self.file_stream = None
+
class WeaveRevisionBuildEditor(RevisionBuildEditor):
"""Subversion commit editor that can write to a weave-based repository.
"""
=== modified file 'format.py'
--- a/format.py 2008-06-17 22:52:33 +0000
+++ b/format.py 2008-06-21 16:21:46 +0000
@@ -83,7 +83,7 @@
"""See BzrDir.initialize_on_transport()."""
from transport import get_svn_ra_transport
from bzrlib.transport.local import LocalTransport
- from svn import repos
+ from bzrlib.plugins.svn import repos
if not isinstance(transport, LocalTransport):
raise NotImplementedError(self.initialize,
@@ -91,7 +91,7 @@
"non-local transports")
local_path = transport._local_base.rstrip("/")
- repos.create(local_path, '', '', None, None)
+ repos.create(local_path)
# All revision property changes
revprop_hook = os.path.join(local_path, "hooks", "pre-revprop-change")
open(revprop_hook, 'w').write("#!/bin/sh")
=== added file 'repos.py'
--- a/repos.py 1970-01-01 00:00:00 +0000
+++ b/repos.py 2008-06-21 16:21:46 +0000
@@ -0,0 +1,42 @@
+# 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/>.
+
+import svn.repos
+
+LOAD_UUID_IGNORE = svn.repos.load_uuid_ignore
+LOAD_UUID_FORCE = svn.repos.load_uuid_force
+LOAD_UUID_DEFAULT = svn.repos.load_uuid_default
+
+def create(path):
+ r = svn.repos.create(path, '', '', None, None)
+ return Repository(path, r)
+
+class Repository:
+ def __init__(self, local_path, _repos=None):
+ if _repos is not None:
+ self.repos = _repos
+ else:
+ self.repos = svn.repos.svn_repos_open(local_path)
+
+ def fs(self):
+ return svn.repos.fs(self.repos)
+
+ def load_fs(self, dumpstream, feedback_stream, uuid_action=LOAD_UUID_DEFAULT,
+ parent_dir="", use_pre_commit_hook=False, use_post_commit_hook=False,
+ cancel_func=None):
+ return svn.repos.load_fs2(self.repos, dumpstream, feedback_stream, uuid_action,
+ parent_dir, use_pre_commit_hook, use_post_commit_hook, cancel_func)
+
+
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2008-06-19 15:33:26 +0000
+++ b/tests/__init__.py 2008-06-21 16:21:46 +0000
@@ -29,7 +29,8 @@
from bzrlib.urlutils import local_path_to_url
from bzrlib.workingtree import WorkingTree
-import svn.core, svn.repos
+import svn.core
+from bzrlib.plugins.svn import repos
from bzrlib.plugins.svn.ra import RemoteAccess
class TestCaseWithSubversionRepository(TestCaseInTempDir):
@@ -52,7 +53,7 @@
"""
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':
@@ -260,9 +261,7 @@
: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'))
More information about the bazaar-commits
mailing list