Rev 5301: (lifeless) Make InterBranch._get_branch_formats_to_test return a list of in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jun 17 10:11:10 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5301 [merge]
revision-id: pqm at pqm.ubuntu.com-20100617091103-254bm3h1n8kpm4wq
parent: pqm at pqm.ubuntu.com-20100617075036-nukzkgr82l4838ps
parent: robertc at robertcollins.net-20100617065030-zdkk10m2lq6cokcb
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-06-17 10:11:03 +0100
message:
  (lifeless) Make InterBranch._get_branch_formats_to_test return a list of
   format pairs to aid testing in bzr-loom. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/tests/per_interbranch/__init__.py __init__.py-20090225010018-l7w4uvvt73ea2vj9-1
  bzrlib/tests/per_interbranch/test_copy_content_into.py test_copy_content_in-20100614063734-p3obbdo8mlwxx77s-1
  bzrlib/tests/per_interbranch/test_get.py test_get.py-20100614063708-wrsytbf6dmeyhb8a-1
  bzrlib/tests/per_interbranch/test_push.py test_push.py-20090330192649-pca31sb2ubbtcs15-1
  bzrlib/tests/per_interbranch/test_update_revisions.py test_update_revision-20090225011043-7u1jnapdeuj07rre-1
=== modified file 'NEWS'
--- a/NEWS	2010-06-17 02:06:20 +0000
+++ b/NEWS	2010-06-17 09:11:03 +0000
@@ -96,10 +96,14 @@
 API Changes
 ***********
 
+* ``bzrlib.branch.InterBranch._get_branch_formats_to_test`` now returns
+  an iterable of format pairs, rather than just a single pair, permitting
+  InterBranch objects that work with multiple permutations to be
+  comprehensively tested. (Robert Collins)
+
 * ``bzrlib.knit.KnitSequenceMatcher``, which has been deprecated since
   2007, has been deleted.  Use ``PatienceSequenceMatcher`` from
-  ``bzrlib.patiencediff`` instead.
-  (Andrew Bennetts)
+  ``bzrlib.patiencediff`` instead. (Andrew Bennetts)
 
 * ``bzrlib.transport.ssh.SSHVendor.connect_ssh`` now returns an object
   that implements the interface of ``bzrlib.transport.ssh.SSHConnection``.

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2010-06-14 21:41:32 +0000
+++ b/bzrlib/branch.py	2010-06-17 06:30:22 +0000
@@ -1023,7 +1023,6 @@
             self._extend_partial_history(distance_from_last)
         return self._partial_revision_history_cache[distance_from_last]
 
-    @needs_write_lock
     def pull(self, source, overwrite=False, stop_revision=None,
              possible_transports=None, *args, **kwargs):
         """Mirror source into this branch.
@@ -3185,11 +3184,17 @@
     _optimisers = []
     """The available optimised InterBranch types."""
 
-    @staticmethod
-    def _get_branch_formats_to_test():
-        """Return a tuple with the Branch formats to use when testing."""
-        raise NotImplementedError(InterBranch._get_branch_formats_to_test)
+    @classmethod
+    def _get_branch_formats_to_test(klass):
+        """Return an iterable of format tuples for testing.
+        
+        :return: An iterable of (from_format, to_format) to use when testing
+            this InterBranch class. Each InterBranch class should define this
+            method itself.
+        """
+        raise NotImplementedError(klass._get_branch_formats_to_test)
 
+    @needs_write_lock
     def pull(self, overwrite=False, stop_revision=None,
              possible_transports=None, local=False):
         """Mirror source into target branch.
@@ -3200,6 +3205,7 @@
         """
         raise NotImplementedError(self.pull)
 
+    @needs_write_lock
     def update_revisions(self, stop_revision=None, overwrite=False,
                          graph=None):
         """Pull in new perfect-fit revisions.
@@ -3213,6 +3219,7 @@
         """
         raise NotImplementedError(self.update_revisions)
 
+    @needs_write_lock
     def push(self, overwrite=False, stop_revision=None,
              _override_hook_source_branch=None):
         """Mirror the source branch into the target branch.
@@ -3230,9 +3237,9 @@
         # GenericBranch uses the public API, so always compatible
         return True
 
-    @staticmethod
-    def _get_branch_formats_to_test():
-        return BranchFormat._default_format, BranchFormat._default_format
+    @classmethod
+    def _get_branch_formats_to_test(klass):
+        return [(BranchFormat._default_format, BranchFormat._default_format)]
 
     @classmethod
     def unwrap_format(klass, format):
@@ -3300,6 +3307,7 @@
                              (this_last_revision, this_revno)])
         self.target.set_last_revision_info(stop_revno, stop_revision)
 
+    @needs_write_lock
     def pull(self, overwrite=False, stop_revision=None,
              possible_transports=None, run_hooks=True,
              _override_hook_target=None, local=False):

=== modified file 'bzrlib/tests/per_interbranch/__init__.py'
--- a/bzrlib/tests/per_interbranch/__init__.py	2010-06-14 06:57:25 +0000
+++ b/bzrlib/tests/per_interbranch/__init__.py	2010-06-16 08:17:50 +0000
@@ -76,11 +76,9 @@
     # test the default InterBranch between format 6 and the current
     # default format.
     for optimiser_class in InterBranch._optimisers:
-        format_from_test, format_to_test = \
-            optimiser_class._get_branch_formats_to_test()
-        if format_to_test is not None:
-            result.append((optimiser_class,
-                           format_from_test, format_to_test))
+        for format_from_test, format_to_test in \
+            optimiser_class._get_branch_formats_to_test():
+            result.append((optimiser_class, format_from_test, format_to_test))
     # if there are specific combinations we want to use, we can add them
     # here.
     return result

=== modified file 'bzrlib/tests/per_interbranch/test_copy_content_into.py'
--- a/bzrlib/tests/per_interbranch/test_copy_content_into.py	2010-06-14 06:57:25 +0000
+++ b/bzrlib/tests/per_interbranch/test_copy_content_into.py	2010-06-17 06:30:22 +0000
@@ -27,14 +27,14 @@
 class TestCopyContentInto(TestCaseWithInterBranch):
 
     def test_contract_convenience_method(self):
-        self.tree1 = self.make_branch_and_tree('tree1')
+        self.tree1 = self.make_from_branch_and_tree('tree1')
         rev1 = self.tree1.commit('one')
         branch2 = self.make_to_branch('tree2')
         branch2.repository.fetch(self.tree1.branch.repository)
         self.tree1.branch.copy_content_into(branch2, revision_id=rev1)
 
     def test_inter_is_used(self):
-        self.tree1 = self.make_branch_and_tree('tree1')
+        self.tree1 = self.make_from_branch_and_tree('tree1')
         self.addCleanup(branch.InterBranch.unregister_optimiser,
             StubMatchingInter)
         branch.InterBranch.register_optimiser(StubMatchingInter)

=== modified file 'bzrlib/tests/per_interbranch/test_get.py'
--- a/bzrlib/tests/per_interbranch/test_get.py	2010-06-14 06:37:11 +0000
+++ b/bzrlib/tests/per_interbranch/test_get.py	2010-06-17 06:30:22 +0000
@@ -24,10 +24,10 @@
     )
 
 
-class TestCopyContentInto(TestCaseWithInterBranch):
+class TestInterBranchGet(TestCaseWithInterBranch):
 
     def test_gets_right_inter(self):
-        self.tree1 = self.make_branch_and_tree('tree1')
+        self.tree1 = self.make_from_branch_and_tree('tree1')
         branch2 = self.make_to_branch('tree2')
         self.assertIs(branch.InterBranch.get(
             self.tree1.branch, branch2).__class__,

=== modified file 'bzrlib/tests/per_interbranch/test_push.py'
--- a/bzrlib/tests/per_interbranch/test_push.py	2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/per_interbranch/test_push.py	2010-06-17 06:30:22 +0000
@@ -145,7 +145,7 @@
         except (errors.IncompatibleFormat, errors.UninitializableFormat):
             # This Branch format cannot create shared repositories
             return
-        # This is a little bit trickier because make_branch_and_tree will not
+        # This is a little bit trickier because make_from_branch_and_tree will not
         # re-use a shared repository.
         try:
             a_branch = self.make_from_branch('repo/tree')

=== modified file 'bzrlib/tests/per_interbranch/test_update_revisions.py'
--- a/bzrlib/tests/per_interbranch/test_update_revisions.py	2009-05-07 05:08:46 +0000
+++ b/bzrlib/tests/per_interbranch/test_update_revisions.py	2010-06-17 06:30:22 +0000
@@ -26,7 +26,7 @@
 
     def setUp(self):
         super(TestUpdateRevisions, self).setUp()
-        self.tree1 = self.make_branch_and_tree('tree1')
+        self.tree1 = self.make_from_branch_and_tree('tree1')
         rev1 = self.tree1.commit('one')
         branch2 = self.make_to_branch('tree2')
         branch2.repository.fetch(self.tree1.branch.repository)




More information about the bazaar-commits mailing list