Rev 3446: Add tests for Branch.missing_revisions and deprecate it. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/missing

John Arbash Meinel john at arbash-meinel.com
Wed May 21 16:42:58 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/missing

------------------------------------------------------------
revno: 3446
revision-id: john at arbash-meinel.com-20080521154247-sqpkv9um9grku9e1
parent: pqm at pqm.ubuntu.com-20080521104134-beoquporep2cpghs
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: missing
timestamp: Wed 2008-05-21 10:42:47 -0500
message:
  Add tests for Branch.missing_revisions and deprecate it.
  
  The api uses a 'stop_revision' but it is supposed to be a revno, not a
  revision_id. The code itself is very crufty and slow (and doesn't take
  a read_lock). But rather than fix it, just nuke the function.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/tests/test_branch.py    test_branch.py-20060116013032-97819aa07b8ab3b5
  bzrlib/tests/test_switch.py    test_switch.py-20071116011000-v5lnw7d2wkng9eux-2
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-05-21 10:41:34 +0000
+++ b/NEWS	2008-05-21 15:42:47 +0000
@@ -78,6 +78,11 @@
 
   INTERNALS:
 
+    * ``Branch.missing_revisions`` has been deprecated. Similar functionality
+      can be obtained using ``bzrlib.missing.find_unmerged``. The api was
+      fairly broken, and the function was unused, so we are getting rid of it.
+      (John Arbash Meinel)
+
   API CHANGES:
 
     * ``bzr missing --mine-only`` will return status code 0 if you have no

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2008-05-08 04:33:38 +0000
+++ b/bzrlib/branch.py	2008-05-21 15:42:47 +0000
@@ -41,6 +41,7 @@
 
 from bzrlib.decorators import needs_read_lock, needs_write_lock
 from bzrlib.hooks import Hooks
+from bzrlib.symbol_versioning import deprecated_in, deprecated_method
 from bzrlib.trace import mutter, mutter_callsite, note, is_quiet
 
 
@@ -420,6 +421,7 @@
         else:
             return (0, _mod_revision.NULL_REVISION)
 
+    @deprecated_method(deprecated_in((1, 6, 0)))
     def missing_revisions(self, other, stop_revision=None):
         """Return a list of new revisions that would perfectly fit.
         

=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py	2008-04-09 03:09:58 +0000
+++ b/bzrlib/tests/test_branch.py	2008-05-21 15:42:47 +0000
@@ -50,9 +50,11 @@
                            UnsupportedFormatError,
                            )
 
+from bzrlib.symbol_versioning import deprecated_in
 from bzrlib.tests import TestCase, TestCaseWithTransport
 from bzrlib.transport import get_transport
 
+
 class TestDefaultFormat(TestCase):
 
     def test_default_format(self):
@@ -128,6 +130,38 @@
     # TODO RBC 20051029 test getting a push location from a branch in a
     # recursive section - that is, it appends the branch name.
 
+    def test_missing_revisions(self):
+        t1 = self.make_branch_and_tree('b1', format='knit')
+        rev1 = t1.commit('one')
+        t2 = t1.bzrdir.sprout('b2').open_workingtree()
+        rev2 = t1.commit('two')
+        rev3 = t1.commit('three')
+
+        self.assertEqual([rev2, rev3],
+            self.applyDeprecated(deprecated_in((1, 6, 0)),
+            t2.branch.missing_revisions, t1.branch))
+
+        self.assertEqual([],
+            self.applyDeprecated(deprecated_in((1, 6, 0)),
+            t2.branch.missing_revisions, t1.branch, stop_revision=1))
+        self.assertEqual([rev2],
+            self.applyDeprecated(deprecated_in((1, 6, 0)),
+            t2.branch.missing_revisions, t1.branch, stop_revision=2))
+        self.assertEqual([rev2, rev3],
+            self.applyDeprecated(deprecated_in((1, 6, 0)),
+            t2.branch.missing_revisions, t1.branch, stop_revision=3))
+
+        self.assertRaises(errors.NoSuchRevision,
+            self.applyDeprecated, deprecated_in((1, 6, 0)),
+            t2.branch.missing_revisions, t1.branch, stop_revision=4)
+
+        rev4 = t2.commit('four')
+        self.assertRaises(errors.DivergedBranches,
+            self.applyDeprecated, deprecated_in((1, 6, 0)),
+            t2.branch.missing_revisions, t1.branch)
+
+            
+
 
 class SampleBranchFormat(BranchFormat):
     """A sample format
@@ -294,6 +328,7 @@
         self.assertEqual(warnings[0], 'Value "new" is masked by "old" from '
                          'locations.conf')
 
+
 class TestBranchReference(TestCaseWithTransport):
     """Tests for the branch reference facility."""
 

=== modified file 'bzrlib/tests/test_switch.py'
--- a/bzrlib/tests/test_switch.py	2007-12-07 05:31:54 +0000
+++ b/bzrlib/tests/test_switch.py	2008-05-21 15:42:47 +0000
@@ -130,7 +130,5 @@
         self.failIfExists('checkout/file-3')
         self.failUnlessExists('checkout/file-4')
         # Check that the checkout is a true mirror of the bound branch
-        missing_in_checkout = checkout.branch.missing_revisions(to_branch)
-        self.assertEqual([], missing_in_checkout)
-        missing_in_remote = to_branch.missing_revisions(checkout.branch)
-        self.assertEqual([], missing_in_remote)
+        self.assertEqual(to_branch.last_revision_info(),
+                         checkout.branch.last_revision_info())



More information about the bazaar-commits mailing list