Rev 5705: (jelmer) Move get_{workingtree, branch, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Mar 8 01:41:48 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5705 [merge]
revision-id: pqm at pqm.ubuntu.com-20110308014146-kflr8jyyx1yahq31
parent: pqm at pqm.ubuntu.com-20110307175219-4wuflxgl4hfzivom
parent: jelmer at samba.org-20110308005951-6olh1ntd1dtn64kd
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-03-08 01:41:46 +0000
message:
(jelmer) Move get_{workingtree, branch,
repository}_transport methods from ControlDir to BzrDir. (Jelmer
Vernooij)
modified:
bzrlib/branch_weave.py branch_weave.py-20110303112759-greg4a9dt5pent0m-1
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/controldir.py controldir.py-20100802102926-hvtvh0uae5epuibp-1
bzrlib/tests/per_bzrdir/test_bzrdir.py test_bzrdir.py-20100829143338-2uachgod1c3liktl-1
bzrlib/tests/per_controldir/test_controldir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
bzrlib/tests/per_controldir_colo/test_unsupported.py test_unsupported.py-20100411192232-kawv9qu1t42gv89k-4
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/branch_weave.py'
--- a/bzrlib/branch_weave.py 2011-03-03 17:01:05 +0000
+++ b/bzrlib/branch_weave.py 2011-03-08 00:59:51 +0000
@@ -108,6 +108,8 @@
def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
found_repository=None):
"""See BranchFormat.open()."""
+ if name is not None:
+ raise errors.NoColocatedBranchSupport(self)
if not _found:
# we are being called directly and must probe.
raise NotImplementedError
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2011-03-07 17:52:19 +0000
+++ b/bzrlib/bzrdir.py 2011-03-08 00:04:05 +0000
@@ -929,6 +929,45 @@
format = controldir.ControlDirFormat.get_default_format()
return format.initialize_on_transport(t)
+ def get_branch_transport(self, branch_format, name=None):
+ """Get the transport for use by branch format in this BzrDir.
+
+ Note that bzr dirs that do not support format strings will raise
+ IncompatibleFormat if the branch format they are given has
+ a format string, and vice versa.
+
+ If branch_format is None, the transport is returned with no
+ checking. If it is not None, then the returned transport is
+ guaranteed to point to an existing directory ready for use.
+ """
+ raise NotImplementedError(self.get_branch_transport)
+
+ def get_repository_transport(self, repository_format):
+ """Get the transport for use by repository format in this BzrDir.
+
+ Note that bzr dirs that do not support format strings will raise
+ IncompatibleFormat if the repository format they are given has
+ a format string, and vice versa.
+
+ If repository_format is None, the transport is returned with no
+ checking. If it is not None, then the returned transport is
+ guaranteed to point to an existing directory ready for use.
+ """
+ raise NotImplementedError(self.get_repository_transport)
+
+ def get_workingtree_transport(self, tree_format):
+ """Get the transport for use by workingtree format in this BzrDir.
+
+ Note that bzr dirs that do not support format strings will raise
+ IncompatibleFormat if the workingtree format they are given has a
+ format string, and vice versa.
+
+ If workingtree_format is None, the transport is returned with no
+ checking. If it is not None, then the returned transport is
+ guaranteed to point to an existing directory ready for use.
+ """
+ raise NotImplementedError(self.get_workingtree_transport)
+
class BzrDirHooks(hooks.Hooks):
"""Hooks for BzrDir operations."""
=== modified file 'bzrlib/controldir.py'
--- a/bzrlib/controldir.py 2011-03-03 01:03:13 +0000
+++ b/bzrlib/controldir.py 2011-03-05 02:54:47 +0000
@@ -215,45 +215,6 @@
raise errors.NoColocatedBranchSupport(self)
return None
- def get_branch_transport(self, branch_format, name=None):
- """Get the transport for use by branch format in this ControlDir.
-
- Note that bzr dirs that do not support format strings will raise
- IncompatibleFormat if the branch format they are given has
- a format string, and vice versa.
-
- If branch_format is None, the transport is returned with no
- checking. If it is not None, then the returned transport is
- guaranteed to point to an existing directory ready for use.
- """
- raise NotImplementedError(self.get_branch_transport)
-
- def get_repository_transport(self, repository_format):
- """Get the transport for use by repository format in this ControlDir.
-
- Note that bzr dirs that do not support format strings will raise
- IncompatibleFormat if the repository format they are given has
- a format string, and vice versa.
-
- If repository_format is None, the transport is returned with no
- checking. If it is not None, then the returned transport is
- guaranteed to point to an existing directory ready for use.
- """
- raise NotImplementedError(self.get_repository_transport)
-
- def get_workingtree_transport(self, tree_format):
- """Get the transport for use by workingtree format in this ControlDir.
-
- Note that bzr dirs that do not support format strings will raise
- IncompatibleFormat if the workingtree format they are given has a
- format string, and vice versa.
-
- If workingtree_format is None, the transport is returned with no
- checking. If it is not None, then the returned transport is
- guaranteed to point to an existing directory ready for use.
- """
- raise NotImplementedError(self.get_workingtree_transport)
-
def open_branch(self, name=None, unsupported=False,
ignore_fallbacks=False):
"""Open the branch object at this ControlDir if one is present.
=== modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py'
--- a/bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-10-05 20:39:07 +0000
+++ b/bzrlib/tests/per_bzrdir/test_bzrdir.py 2011-03-08 00:53:45 +0000
@@ -22,8 +22,10 @@
import bzrlib.branch
from bzrlib import (
errors,
+ repository,
revision as _mod_revision,
transport,
+ workingtree,
)
from bzrlib.tests import (
TestSkipped,
@@ -34,6 +36,48 @@
)
+class AnonymousTestBranchFormat(bzrlib.branch.BranchFormat):
+ """An anonymous branch format (does not have a format string)"""
+
+ def get_format_string(self):
+ raise NotImplementedError(self.get_format_string)
+
+
+class IdentifiableTestBranchFormat(bzrlib.branch.BranchFormat):
+ """An identifable branch format (has a format string)"""
+
+ def get_format_string(self):
+ return "I have an identity"
+
+
+class AnonymousTestRepositoryFormat(repository.RepositoryFormat):
+ """An anonymous branch format (does not have a format string)"""
+
+ def get_format_string(self):
+ raise NotImplementedError(self.get_format_string)
+
+
+class IdentifiableTestRepositoryFormat(repository.RepositoryFormat):
+ """An identifable branch format (has a format string)"""
+
+ def get_format_string(self):
+ return "I have an identity"
+
+
+class AnonymousTestWorkingTreeFormat(workingtree.WorkingTreeFormat):
+ """An anonymous branch format (does not have a format string)"""
+
+ def get_format_string(self):
+ raise NotImplementedError(self.get_format_string)
+
+
+class IdentifiableTestWorkingTreeFormat(workingtree.WorkingTreeFormat):
+ """An identifable branch format (has a format string)"""
+
+ def get_format_string(self):
+ return "I have an identity"
+
+
class TestBzrDir(TestCaseWithBzrDir):
# Many of these tests test for disk equality rather than checking
@@ -490,3 +534,66 @@
self.failUnless(transport.has('.bzr'))
self.assertRaises((errors.FileExists, errors.DirectoryNotEmpty),
bd.retire_bzrdir, limit=0)
+
+ def test_get_branch_transport(self):
+ dir = self.make_bzrdir('.')
+ # without a format, get_branch_transport gives use a transport
+ # which -may- point to an existing dir.
+ self.assertTrue(isinstance(dir.get_branch_transport(None),
+ transport.Transport))
+ # with a given format, either the bzr dir supports identifiable
+ # branches, or it supports anonymous branch formats, but not both.
+ anonymous_format = AnonymousTestBranchFormat()
+ identifiable_format = IdentifiableTestBranchFormat()
+ try:
+ found_transport = dir.get_branch_transport(anonymous_format)
+ self.assertRaises(errors.IncompatibleFormat,
+ dir.get_branch_transport,
+ identifiable_format)
+ except errors.IncompatibleFormat:
+ found_transport = dir.get_branch_transport(identifiable_format)
+ self.assertTrue(isinstance(found_transport, transport.Transport))
+ # and the dir which has been initialized for us must exist.
+ found_transport.list_dir('.')
+
+ def test_get_repository_transport(self):
+ dir = self.make_bzrdir('.')
+ # without a format, get_repository_transport gives use a transport
+ # which -may- point to an existing dir.
+ self.assertTrue(isinstance(dir.get_repository_transport(None),
+ transport.Transport))
+ # with a given format, either the bzr dir supports identifiable
+ # repositories, or it supports anonymous repository formats, but not both.
+ anonymous_format = AnonymousTestRepositoryFormat()
+ identifiable_format = IdentifiableTestRepositoryFormat()
+ try:
+ found_transport = dir.get_repository_transport(anonymous_format)
+ self.assertRaises(errors.IncompatibleFormat,
+ dir.get_repository_transport,
+ identifiable_format)
+ except errors.IncompatibleFormat:
+ found_transport = dir.get_repository_transport(identifiable_format)
+ self.assertTrue(isinstance(found_transport, transport.Transport))
+ # and the dir which has been initialized for us must exist.
+ found_transport.list_dir('.')
+
+ def test_get_workingtree_transport(self):
+ dir = self.make_bzrdir('.')
+ # without a format, get_workingtree_transport gives use a transport
+ # which -may- point to an existing dir.
+ self.assertTrue(isinstance(dir.get_workingtree_transport(None),
+ transport.Transport))
+ # with a given format, either the bzr dir supports identifiable
+ # trees, or it supports anonymous tree formats, but not both.
+ anonymous_format = AnonymousTestWorkingTreeFormat()
+ identifiable_format = IdentifiableTestWorkingTreeFormat()
+ try:
+ found_transport = dir.get_workingtree_transport(anonymous_format)
+ self.assertRaises(errors.IncompatibleFormat,
+ dir.get_workingtree_transport,
+ identifiable_format)
+ except errors.IncompatibleFormat:
+ found_transport = dir.get_workingtree_transport(identifiable_format)
+ self.assertTrue(isinstance(found_transport, transport.Transport))
+ # and the dir which has been initialized for us must exist.
+ found_transport.list_dir('.')
=== modified file 'bzrlib/tests/per_controldir/test_controldir.py'
--- a/bzrlib/tests/per_controldir/test_controldir.py 2011-03-06 00:33:01 +0000
+++ b/bzrlib/tests/per_controldir/test_controldir.py 2011-03-08 00:53:45 +0000
@@ -50,48 +50,6 @@
)
-class AnonymousTestBranchFormat(bzrlib.branch.BranchFormat):
- """An anonymous branch format (does not have a format string)"""
-
- def get_format_string(self):
- raise NotImplementedError(self.get_format_string)
-
-
-class IdentifiableTestBranchFormat(bzrlib.branch.BranchFormat):
- """An identifable branch format (has a format string)"""
-
- def get_format_string(self):
- return "I have an identity"
-
-
-class AnonymousTestRepositoryFormat(repository.RepositoryFormat):
- """An anonymous branch format (does not have a format string)"""
-
- def get_format_string(self):
- raise NotImplementedError(self.get_format_string)
-
-
-class IdentifiableTestRepositoryFormat(repository.RepositoryFormat):
- """An identifable branch format (has a format string)"""
-
- def get_format_string(self):
- return "I have an identity"
-
-
-class AnonymousTestWorkingTreeFormat(workingtree.WorkingTreeFormat):
- """An anonymous branch format (does not have a format string)"""
-
- def get_format_string(self):
- raise NotImplementedError(self.get_format_string)
-
-
-class IdentifiableTestWorkingTreeFormat(workingtree.WorkingTreeFormat):
- """An identifable branch format (has a format string)"""
-
- def get_format_string(self):
- return "I have an identity"
-
-
class TestControlDir(TestCaseWithControlDir):
def skipIfNoWorkingTree(self, a_bzrdir):
@@ -1316,69 +1274,6 @@
self.failUnless(isinstance(opened_tree, made_tree.__class__))
self.failUnless(isinstance(opened_tree._format, made_tree._format.__class__))
- def test_get_branch_transport(self):
- dir = self.make_bzrdir('.')
- # without a format, get_branch_transport gives use a transport
- # which -may- point to an existing dir.
- self.assertTrue(isinstance(dir.get_branch_transport(None),
- transport.Transport))
- # with a given format, either the bzr dir supports identifiable
- # branches, or it supports anonymous branch formats, but not both.
- anonymous_format = AnonymousTestBranchFormat()
- identifiable_format = IdentifiableTestBranchFormat()
- try:
- found_transport = dir.get_branch_transport(anonymous_format)
- self.assertRaises(errors.IncompatibleFormat,
- dir.get_branch_transport,
- identifiable_format)
- except errors.IncompatibleFormat:
- found_transport = dir.get_branch_transport(identifiable_format)
- self.assertTrue(isinstance(found_transport, transport.Transport))
- # and the dir which has been initialized for us must exist.
- found_transport.list_dir('.')
-
- def test_get_repository_transport(self):
- dir = self.make_bzrdir('.')
- # without a format, get_repository_transport gives use a transport
- # which -may- point to an existing dir.
- self.assertTrue(isinstance(dir.get_repository_transport(None),
- transport.Transport))
- # with a given format, either the bzr dir supports identifiable
- # repositories, or it supports anonymous repository formats, but not both.
- anonymous_format = AnonymousTestRepositoryFormat()
- identifiable_format = IdentifiableTestRepositoryFormat()
- try:
- found_transport = dir.get_repository_transport(anonymous_format)
- self.assertRaises(errors.IncompatibleFormat,
- dir.get_repository_transport,
- identifiable_format)
- except errors.IncompatibleFormat:
- found_transport = dir.get_repository_transport(identifiable_format)
- self.assertTrue(isinstance(found_transport, transport.Transport))
- # and the dir which has been initialized for us must exist.
- found_transport.list_dir('.')
-
- def test_get_workingtree_transport(self):
- dir = self.make_bzrdir('.')
- # without a format, get_workingtree_transport gives use a transport
- # which -may- point to an existing dir.
- self.assertTrue(isinstance(dir.get_workingtree_transport(None),
- transport.Transport))
- # with a given format, either the bzr dir supports identifiable
- # trees, or it supports anonymous tree formats, but not both.
- anonymous_format = AnonymousTestWorkingTreeFormat()
- identifiable_format = IdentifiableTestWorkingTreeFormat()
- try:
- found_transport = dir.get_workingtree_transport(anonymous_format)
- self.assertRaises(errors.IncompatibleFormat,
- dir.get_workingtree_transport,
- identifiable_format)
- except errors.IncompatibleFormat:
- found_transport = dir.get_workingtree_transport(identifiable_format)
- self.assertTrue(isinstance(found_transport, transport.Transport))
- # and the dir which has been initialized for us must exist.
- found_transport.list_dir('.')
-
def test_root_transport(self):
dir = self.make_bzrdir('.')
self.assertEqual(dir.root_transport.base,
=== modified file 'bzrlib/tests/per_controldir_colo/test_unsupported.py'
--- a/bzrlib/tests/per_controldir_colo/test_unsupported.py 2011-01-27 13:58:35 +0000
+++ b/bzrlib/tests/per_controldir_colo/test_unsupported.py 2011-03-05 03:53:34 +0000
@@ -57,10 +57,10 @@
self.assertRaises(errors.NoColocatedBranchSupport,
made_control.create_branch, "colo")
- def test_branch_transport(self):
+ def test_open_branch(self):
made_control = self.make_bzrdir_with_repo()
self.assertRaises(errors.NoColocatedBranchSupport,
- made_control.get_branch_transport, None, "colo")
+ made_control.open_branch, name="colo")
def test_get_branch_reference(self):
made_control = self.make_bzrdir_with_repo()
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-03-03 10:56:25 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-03-06 22:45:05 +0000
@@ -170,6 +170,10 @@
indicates whether the components of the bzrdir can be upgraded
independent of the ``BzrDir``. (Jelmer Vernooij)
+* ``ControlDir`` implementations no longer have to provide the ``get_branch_transport``,
+ ``get_workingtree_transport`` and ``get_repository_transport`` methods.
+ (Jelmer Vernooij, #730325)
+
* ``Converter`` has been moved from ``bzrlib.bzrdir`` to
``bzrlib.controldir``. (Jelmer Vernooij)
More information about the bazaar-commits
mailing list