Rev 2191: Fix test_format_initialize_find_open by delegating Branch formt lookup to the BzrDir, where it should have stayed from the start. in http://bazaar.launchpad.net/~bzr/bzr/hpss

Robert Collins robertc at robertcollins.net
Thu Mar 29 06:02:00 BST 2007


At http://bazaar.launchpad.net/~bzr/bzr/hpss

------------------------------------------------------------
revno: 2191
revision-id: robertc at robertcollins.net-20070329050040-mihvse1hk4mu7mxk
parent: robertc at robertcollins.net-20070329042156-28vdpsyvcbrw7wy9
committer: Robert Collins <robertc at robertcollins.net>
branch nick: hpss
timestamp: Thu 2007-03-29 15:00:40 +1000
message:
  Fix test_format_initialize_find_open by delegating Branch formt lookup to the BzrDir, where it should have stayed from the start.
modified:
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2007-03-27 06:42:26 +0000
+++ b/bzrlib/bzrdir.py	2007-03-29 05:00:40 +0000
@@ -1035,6 +1035,14 @@
     def destroy_workingtree_metadata(self):
         self.transport.delete_tree('checkout')
 
+    def find_branch_format(self):
+        """Find the branch 'format' for this bzrdir.
+
+        This might be a synthetic object for e.g. RemoteBranch and SVN.
+        """
+        from bzrlib.branch import BranchFormat
+        return BranchFormat.find_format(self)
+
     def _get_mkdir_mode(self):
         """Figure out the mode to use when creating a bzrdir subdir."""
         temp_control = lockable_files.LockableFiles(self.transport, '',
@@ -1122,8 +1130,7 @@
 
     def open_branch(self, unsupported=False):
         """See BzrDir.open_branch."""
-        from bzrlib.branch import BranchFormat
-        format = BranchFormat.find_format(self)
+        format = self.find_branch_format()
         self._check_supported(format, unsupported)
         return format.open(self, _found=True)
 

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-03-29 04:21:56 +0000
+++ b/bzrlib/remote.py	2007-03-29 05:00:40 +0000
@@ -85,6 +85,14 @@
         real_workingtree = self._real_bzrdir.create_workingtree(revision_id=revision_id)
         return RemoteWorkingTree(self, real_workingtree)
 
+    def find_branch_format(self):
+        """Find the branch 'format' for this bzrdir.
+
+        This might be a synthetic object for e.g. RemoteBranch and SVN.
+        """
+        b = self.open_branch()
+        return b._format
+
     def open_branch(self, _unsupported=False):
         assert _unsupported == False, 'unsupported flag support not implemented yet.'
         path = self._path_for_remote_call(self._client)
@@ -614,6 +622,10 @@
 
 class RemoteBranchFormat(branch.BranchFormat):
 
+    def __eq__(self, other):
+        return (isinstance(other, RemoteBranchFormat) and 
+            self.__dict__ == other.__dict__)
+
     def get_format_description(self):
         return 'Remote BZR Branch'
 

=== modified file 'bzrlib/tests/branch_implementations/test_branch.py'
--- a/bzrlib/tests/branch_implementations/test_branch.py	2007-03-28 22:54:43 +0000
+++ b/bzrlib/tests/branch_implementations/test_branch.py	2007-03-29 05:00:40 +0000
@@ -655,8 +655,7 @@
             self.branch_format.get_format_string()
         except NotImplementedError:
             return
-        self.assertEqual(self.branch_format,
-                         branch.BranchFormat.find_format(opened_control))
+        self.assertEqual(self.branch_format, opened_control.find_branch_format())
 
 
 class TestBound(TestCaseWithBranch):



More information about the bazaar-commits mailing list