Rev 6211: (jelmer) Add ControlDirFormat.supports_transport(). (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Oct 13 13:44:09 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6211 [merge]
revision-id: pqm at pqm.ubuntu.com-20111013134409-bqexgj0ar8dw1y9c
parent: pqm at pqm.ubuntu.com-20111012210410-y1vdq7fhuhqlk61x
parent: jelmer at samba.org-20111010133625-brnx505rhhpqrp1j
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-10-13 13:44:09 +0000
message:
(jelmer) Add ControlDirFormat.supports_transport(). (Jelmer Vernooij)
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/controldir.py controldir.py-20100802102926-hvtvh0uae5epuibp-1
bzrlib/tests/per_branch/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/tests/per_controldir/test_format.py test_format.py-20110312004133-k0plu1qapsfxadfd-1
bzrlib/tests/per_repository/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2011-10-11 20:18:09 +0000
+++ b/bzrlib/bzrdir.py 2011-10-13 13:44:09 +0000
@@ -1729,6 +1729,10 @@
:return: None.
"""
+ def supports_transport(self, transport):
+ # bzr formats can be opened over all known transports
+ return True
+
class BzrDirMetaFormat1(BzrDirFormat):
"""Bzr meta control format 1
=== modified file 'bzrlib/controldir.py'
--- a/bzrlib/controldir.py 2011-09-23 14:11:20 +0000
+++ b/bzrlib/controldir.py 2011-10-10 12:47:25 +0000
@@ -853,6 +853,11 @@
"""Return the current default format."""
return klass._default_format
+ def supports_transport(self, transport):
+ """Check if this format can be opened over a particular transport.
+ """
+ raise NotImplementedError(self.supports_transport)
+
class Prober(object):
"""Abstract class that can be used to detect a particular kind of
=== modified file 'bzrlib/tests/per_branch/test_branch.py'
--- a/bzrlib/tests/per_branch/test_branch.py 2011-10-10 14:03:32 +0000
+++ b/bzrlib/tests/per_branch/test_branch.py 2011-10-13 13:44:09 +0000
@@ -446,7 +446,11 @@
tree_a = self.make_branch_and_tree('a')
rev_id = tree_a.commit('put some content in the branch')
# open the branch via a readonly transport
- source_branch = _mod_branch.Branch.open(self.get_readonly_url('a'))
+ url = self.get_readonly_url('a')
+ t = transport.get_transport_from_url(url)
+ if not tree_a.branch.bzrdir._format.supports_transport(t):
+ raise tests.TestNotApplicable("format does not support transport")
+ source_branch = _mod_branch.Branch.open(url)
# sanity check that the test will be valid
self.assertRaises((errors.LockError, errors.TransportNotPossible),
source_branch.lock_write)
@@ -534,6 +538,9 @@
_mod_branch.Branch.open_containing,
self.get_readonly_url('g/p/q'))
branch = self.make_branch('.')
+ if not branch.bzrdir._format.supports_transport(
+ transport.get_transport_from_url(self.get_readonly_url('.'))):
+ raise tests.TestNotApplicable("format does not support transport")
branch, relpath = _mod_branch.Branch.open_containing(
self.get_readonly_url(''))
self.assertEqual('', relpath)
=== modified file 'bzrlib/tests/per_controldir/test_format.py'
--- a/bzrlib/tests/per_controldir/test_format.py 2011-03-22 12:10:34 +0000
+++ b/bzrlib/tests/per_controldir/test_format.py 2011-10-10 12:47:25 +0000
@@ -35,6 +35,10 @@
def test_upgrade_recommended(self):
self.assertIsInstance(self.bzrdir_format.upgrade_recommended, bool)
+ def test_supports_transport(self):
+ self.assertIsInstance(
+ self.bzrdir_format.supports_transport(self.get_transport()), bool)
+
def test_check_support_status(self):
if not self.bzrdir_format.is_supported():
self.assertRaises(errors.UnsupportedFormatError,
=== modified file 'bzrlib/tests/per_repository/test_fetch.py'
--- a/bzrlib/tests/per_repository/test_fetch.py 2011-10-04 14:08:14 +0000
+++ b/bzrlib/tests/per_repository/test_fetch.py 2011-10-10 12:47:25 +0000
@@ -335,6 +335,8 @@
def test_fetch_into_smart_with_ghost(self):
trans = self.make_smart_server('target')
source_b = self.make_simple_branch_with_ghost()
+ if not source_b.bzrdir._format.supports_transport(trans):
+ raise TestNotApplicable("format does not support transport")
target = self.make_repository('target')
# Re-open the repository over the smart protocol
target = repository.Repository.open(trans.base)
@@ -352,6 +354,8 @@
def test_fetch_from_smart_with_ghost(self):
trans = self.make_smart_server('source')
source_b = self.make_simple_branch_with_ghost()
+ if not source_b.bzrdir._format.supports_transport(trans):
+ raise TestNotApplicable("format does not support transport")
target = self.make_repository('target')
target.lock_write()
self.addCleanup(target.unlock)
=== modified file 'bzrlib/tests/per_repository/test_repository.py'
--- a/bzrlib/tests/per_repository/test_repository.py 2011-09-24 13:00:34 +0000
+++ b/bzrlib/tests/per_repository/test_repository.py 2011-10-10 13:36:25 +0000
@@ -611,6 +611,9 @@
self.start_server(smart_server, self.get_server())
remote_transport = transport.get_transport_from_url(
smart_server.get_url()).clone(path)
+ if not repo.bzrdir._format.supports_transport(remote_transport):
+ raise tests.TestNotApplicable(
+ "format does not support transport")
remote_bzrdir = bzrdir.BzrDir.open_from_transport(remote_transport)
remote_repo = remote_bzrdir.open_repository()
return remote_repo
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-10-12 16:00:13 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-10-13 13:44:09 +0000
@@ -63,6 +63,10 @@
.. Major internal changes, unlikely to be visible to users or plugin
developers, but interesting for bzr developers.
+* ``ControlDirFormat`` now has a new method ``supports_transport``
+ which format implementations can use whether or not they can access
+ a control dir over a particular transport. (Jelmer Vernooij)
+
Testing
*******
More information about the bazaar-commits
mailing list