Rev 342: Properly implement SvnRemoteAccess.open_repository() and in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Sun Dec 31 20:04:45 GMT 2006
------------------------------------------------------------
revno: 342
revision-id: jelmer at samba.org-20061231200311-yesyt819xp8bbs03
parent: jelmer at samba.org-20061231033910-r3ks4rqiwpmiwhqy
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Sun 2006-12-31 21:03:11 +0100
message:
Properly implement SvnRemoteAccess.open_repository() and
SvnRemoteAccess.find_repository(). open_repository() now no longer
works on non-repository BzrDirs
Try to reduce the amount of TCP/IP connections overall.
added:
tests/test_radir.py test_radir.py-20061231173434-31utf9o4byu7wktm-1
modified:
branchprops.py branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
checkout.py workingtree.py-20060306120941-b083cb0fdd4a69de
format.py format.py-20060406233823-b6fa009fe35dfde7
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/__init__.py __init__.py-20060508151940-e9f4d914801a2535
tests/test_branch.py test_branch.py-20060508162215-74ffeb5d608f8e20
tests/test_fileids.py test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
tests/test_repos.py test_repos.py-20060508151940-ddc49a59257ca712
tests/test_transport.py test_transport.py-20060621232111-xh7xvoblzsrgj79t-1
transport.py transport.py-20060406231150-b3472d06b3a0818d
=== added file 'tests/test_radir.py'
--- a/tests/test_radir.py 1970-01-01 00:00:00 +0000
+++ b/tests/test_radir.py 2006-12-31 20:03:11 +0000
@@ -0,0 +1,58 @@
+# Copyright (C) 2006 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from bzrlib.bzrdir import BzrDir
+from bzrlib.errors import NoRepositoryPresent
+from bzrlib.tests import TestCase
+
+from format import SvnRemoteAccess
+from repository import SvnRepository
+from tests import TestCaseWithSubversionRepository
+
+class TestRemoteAccess(TestCaseWithSubversionRepository):
+ def test_create(self):
+ repos_url = self.make_client("d", "dc")
+ x = BzrDir.open(repos_url)
+ self.assertTrue(hasattr(x, 'svn_root_url'))
+
+ def test_open_repos_root(self):
+ repos_url = self.make_client("d", "dc")
+ x = BzrDir.open(repos_url)
+ repos = x.open_repository()
+ self.assertTrue(hasattr(repos, 'uuid'))
+
+ def test_find_repos_nonroot(self):
+ repos_url = self.make_client("d", "dc")
+ self.build_tree({'dc/trunk': None})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "data")
+ x = BzrDir.open(repos_url+"/trunk")
+ repos = x.find_repository()
+ self.assertTrue(hasattr(repos, 'uuid'))
+
+ def test_find_repos_root(self):
+ repos_url = self.make_client("d", "dc")
+ x = BzrDir.open(repos_url)
+ repos = x.find_repository()
+ self.assertTrue(hasattr(repos, 'uuid'))
+
+ def test_open_repos_nonroot(self):
+ repos_url = self.make_client("d", "dc")
+ self.build_tree({'dc/trunk': None})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "data")
+ x = BzrDir.open(repos_url+"/trunk")
+ self.assertRaises(NoRepositoryPresent, x.open_repository)
=== modified file 'branchprops.py'
--- a/branchprops.py 2006-12-26 19:58:41 +0000
+++ b/branchprops.py 2006-12-31 20:03:11 +0000
@@ -35,8 +35,7 @@
path = path.lstrip("/")
try:
- (_, _, props) = self.log.transport.get_dir(
- path.encode('utf8'),
+ (_, _, props) = self.log.transport.get_dir(path.encode('utf8'),
revnum, pool=self.pool)
except SubversionException, (msg, num):
if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
=== modified file 'checkout.py'
--- a/checkout.py 2006-12-23 21:38:26 +0000
+++ b/checkout.py 2006-12-31 20:03:11 +0000
@@ -482,7 +482,7 @@
svn.wc.adm_close(wc)
self.remote_transport = SvnRaTransport(svn_url)
- self.svn_root_transport = self.remote_transport.get_root()
+ self.svn_root_transport = SvnRaTransport(self.remote_transport.get_repos_root())
self.root_transport = self.transport = transport
self.branch_path = svn_url[len(bzr_to_svn_url(self.svn_root_transport.base)):]
=== modified file 'format.py'
--- a/format.py 2006-12-30 17:43:09 +0000
+++ b/format.py 2006-12-31 20:03:11 +0000
@@ -41,13 +41,11 @@
_transport = get_svn_ra_transport(_transport)
super(SvnRemoteAccess, self).__init__(_transport, _format)
- self.svn_root_transport = _transport.get_root()
-
svn_url = bzr_to_svn_url(self.root_transport.base)
- root_svn_url = bzr_to_svn_url(self.svn_root_transport.base)
+ self.svn_root_url = _transport.get_repos_root()
- assert svn_url.startswith(root_svn_url)
- self.branch_path = svn_url[len(root_svn_url):]
+ assert svn_url.startswith(self.svn_root_url)
+ self.branch_path = svn_url[len(self.svn_root_url):]
if scheme is None:
self.scheme = BranchingScheme.guess_scheme(self.branch_path)
@@ -68,7 +66,7 @@
def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
"""See BzrDir.sprout()."""
result = BzrDirFormat.get_default_format().initialize(url)
- repo = self.open_repository()
+ repo = self.find_repository()
if force_new_repo:
result_repo = repo.clone(result, revision_id, basis)
else:
@@ -89,12 +87,16 @@
:return: instance of SvnRepository.
"""
- repos = SvnRepository(self, self.svn_root_transport)
- return repos
+ if self.branch_path == "":
+ return SvnRepository(self, SvnRaTransport(self.svn_root_url))
+ raise NoRepositoryPresent(self)
- # Subversion has all-in-one, so a repository is always present,
- # no need to look for it.
- find_repository = open_repository
+ def find_repository(self):
+ """Open the repository associated with this BzrDir.
+
+ :return: instance of SvnRepository.
+ """
+ return SvnRepository(self, SvnRaTransport(self.svn_root_url))
def open_workingtree(self):
"""See BzrDir.open_workingtree().
@@ -128,10 +130,8 @@
if not self.scheme.is_branch(self.branch_path):
raise NotBranchError(path=self.root_transport.base)
- repos = self.open_repository()
-
+ repos = self.find_repository()
branch = SvnBranch(self.root_transport.base, repos, self.branch_path)
-
branch.bzrdir = self
return branch
=== modified file 'repository.py'
--- a/repository.py 2006-12-31 03:39:10 +0000
+++ b/repository.py 2006-12-31 20:03:11 +0000
@@ -115,6 +115,7 @@
return NULL_REVISION
return "%s%d@%s-%s" % (REVISION_ID_PREFIX, revnum, uuid, escape_svn_path(path.strip("/")))
+
def parse_revision_id(self, revid):
"""Parse an existing Subversion-based revision id.
@@ -142,6 +143,7 @@
(uuid, branch, revnum) = feature.split(":")
return generate_svn_revision_id(uuid, int(revnum), branch.strip("/"))
+
def revision_id_to_svk_feature(revid):
"""Create a SVK feature identifier from a revision id.
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2006-12-23 21:38:26 +0000
+++ b/tests/__init__.py 2006-12-31 20:03:11 +0000
@@ -235,6 +235,7 @@
'test_convert',
'test_fileids',
'test_logwalker',
+ 'test_radir',
'test_repos',
'test_scheme',
'test_transport',
=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py 2006-12-29 21:15:51 +0000
+++ b/tests/test_branch.py 2006-12-31 20:03:11 +0000
@@ -44,7 +44,7 @@
bzrdir = BzrDir.open("svn+"+repos_url)
branch = bzrdir.open_branch()
- repos = bzrdir.open_repository()
+ repos = bzrdir.find_repository()
self.assertEqual("svn-v%d:1@%s-" % (MAPPING_VERSION, repos.uuid),
branch.last_revision())
@@ -410,7 +410,7 @@
newbranch = newdir.open_branch()
- uuid = olddir.open_repository().uuid
+ uuid = olddir.find_repository().uuid
tree = newbranch.repository.revision_tree(
"svn-v%d:6@%s-branches%%2ffoobranch" % (MAPPING_VERSION, uuid))
@@ -495,9 +495,9 @@
os.mkdir("dc")
newdir = olddir.sprout('dc')
- newdir.open_repository().get_revision(
+ newdir.find_repository().get_revision(
newdir.open_branch().last_revision())
- newdir.open_repository().get_revision_inventory(
+ newdir.find_repository().get_revision_inventory(
newdir.open_branch().last_revision())
class TestFakeControlFiles(TestCase):
=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py 2006-12-29 23:18:29 +0000
+++ b/tests/test_fileids.py 2006-12-31 20:03:11 +0000
@@ -75,7 +75,7 @@
self.client_commit("dc", "Second Message")
bzrdir = BzrDir.open("svn+%s" % repos_url)
- repository = bzrdir.open_repository()
+ repository = bzrdir.find_repository()
inv1 = repository.get_inventory(
"svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid))
@@ -95,7 +95,7 @@
self.client_commit("dc", "Second Message")
bzrdir = BzrDir.open("svn+%s" % repos_url)
- repository = bzrdir.open_repository()
+ repository = bzrdir.find_repository()
inv1 = repository.get_inventory(
"svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid))
@@ -115,7 +115,7 @@
self.client_commit("dc", "Second Message")
bzrdir = BzrDir.open("svn+"+repos_url)
- repository = bzrdir.open_repository()
+ repository = bzrdir.find_repository()
inv1 = repository.get_inventory(
"svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid))
@@ -133,7 +133,7 @@
self.client_commit("dc", "Copy branch")
bzrdir = BzrDir.open("svn+"+repos_url + "/branches/mybranch")
- repository = bzrdir.open_repository()
+ repository = bzrdir.find_repository()
inv1 = repository.get_inventory(
"svn-v%d:1@%s-trunk" % (MAPPING_VERSION, repository.uuid))
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2006-12-30 21:08:37 +0000
+++ b/tests/test_repos.py 2006-12-31 20:03:11 +0000
@@ -218,13 +218,13 @@
""" Test UUID is retrieved correctly """
bzrdir = self.make_local_bzrdir('c', 'cc')
self.assertTrue(isinstance(bzrdir, BzrDir))
- repository = bzrdir.open_repository()
+ repository = bzrdir.find_repository()
fs = self.open_fs('c')
self.assertEqual(svn.fs.get_uuid(fs), repository.uuid)
def test_has_revision(self):
bzrdir = self.make_client_and_bzrdir('d', 'dc')
- repository = bzrdir.open_repository()
+ repository = bzrdir.find_repository()
self.build_tree({'dc/foo': "data"})
self.client_add("dc/foo")
self.client_commit("dc", "My Message")
@@ -234,7 +234,7 @@
def test_has_revision_none(self):
bzrdir = self.make_client_and_bzrdir('d', 'dc')
- repository = bzrdir.open_repository()
+ repository = bzrdir.find_repository()
self.assertTrue(repository.has_revision(None))
def test_revision_parents(self):
@@ -544,7 +544,8 @@
self.client_add("dc/branches")
self.client_commit("dc", "foohosts") #4
- oldrepos = Repository.open("svn+"+repos_url+"/trunk")
+ oldrepos = Repository.open("svn+"+repos_url)
+ oldrepos.set_branching_scheme(TrunkBranchingScheme())
dir = BzrDir.create("f")
newrepos = dir.create_repository()
oldrepos.copy_content_into(newrepos)
@@ -1509,7 +1510,7 @@
self.client_commit("dc", "foohosts") #4
oldrepos = format.SvnRemoteAccess(SvnRaTransport("svn+"+repos_url), format.SvnFormat(),
- TrunkBranchingScheme()).open_repository()
+ TrunkBranchingScheme()).find_repository()
dir = BzrDir.create("f")
newrepos = dir.create_repository()
oldrepos.copy_content_into(newrepos)
@@ -1552,7 +1553,7 @@
self.client_commit("dc", "foohosts") #6
repos = format.SvnRemoteAccess(SvnRaTransport("svn+"+repos_url), format.SvnFormat(),
- TrunkBranchingScheme()).open_repository()
+ TrunkBranchingScheme()).find_repository()
tree = repos.revision_tree(
"svn-v%d:6@%s-branches%%2ffoobranch" % (MAPPING_VERSION, repos.uuid))
@@ -1695,7 +1696,8 @@
self.client_add("dc/branches/abranch/bdir/stationary/traveller")
self.client_commit("dc", "Change dir")
- oldrepos = Repository.open("svn+"+repos_url+"/trunk")
+ oldrepos = Repository.open("svn+"+repos_url)
+ oldrepos.set_branching_scheme(TrunkBranchingScheme())
dir = BzrDir.create("f")
newrepos = dir.create_repository()
copyrev = "svn-v%d:2@%s-branches%%2fabranch" % (MAPPING_VERSION, oldrepos.uuid)
=== modified file 'tests/test_transport.py'
--- a/tests/test_transport.py 2006-12-25 17:12:14 +0000
+++ b/tests/test_transport.py 2006-12-31 20:03:11 +0000
@@ -140,8 +140,8 @@
self.client_commit("dc", "Bla")
t = SvnRaTransport("%s/dir" % repos_url)
- root = t.get_root()
- self.assertEqual(repos_url, root.base)
+ root = t.get_repos_root()
+ self.assertEqual(repos_url, root)
class UrlConversionTest(TestCase):
=== modified file 'transport.py'
--- a/transport.py 2006-12-27 04:21:19 +0000
+++ b/transport.py 2006-12-31 20:03:11 +0000
@@ -232,14 +232,6 @@
def get_commit_editor(self, *args, **kwargs):
return svn.ra.get_commit_editor(self._ra, *args, **kwargs)
- def get_root(self):
- """Open a connection to the root of this repository.
-
- :return: A new instance of SvnRaTransport connected to the root.
- """
- root_url = self.get_repos_root()
- return SvnRaTransport(root_url)
-
def listable(self):
"""See Transport.listable().
"""
More information about the bazaar-commits
mailing list