Rev 3481: do some amount of checking to ensure that we don't iterate the whole history for mainline nodes. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/lazy_revno

John Arbash Meinel john at arbash-meinel.com
Mon Jun 16 23:22:16 BST 2008


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

------------------------------------------------------------
revno: 3481
revision-id: john at arbash-meinel.com-20080616222146-h41zbinrrtkygznq
parent: john at arbash-meinel.com-20080616205940-vbpyk2owzrwxw4za
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: lazy_revno
timestamp: Mon 2008-06-16 17:21:46 -0500
message:
  do some amount of checking to ensure that we don't iterate the whole history for mainline nodes.
-------------- next part --------------
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2008-06-16 20:59:40 +0000
+++ b/bzrlib/graph.py	2008-06-16 22:21:46 +0000
@@ -1562,4 +1562,8 @@
                             node.set_possible_merged_into(merged_into)
                 else:
                     next_node = None
+            if cur_node.revno is not None:
+                # We have a node where we know the revno, so we will know the
+                # mainline revno involved.
+                break
             cur_node = next_node

=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py	2008-06-16 20:59:40 +0000
+++ b/bzrlib/tests/test_graph.py	2008-06-16 22:21:46 +0000
@@ -1358,9 +1358,11 @@
 
 class TestLazyRevnoMapper(TestGraphBase):
 
-    def make_mapper(self, ancestors, tip):
+    def make_mapper(self, ancestors, tip, break_on=None):
         graph = self.make_graph(ancestors)
         tip_revno = graph.find_distance_to_null(tip, [])
+        if break_on is not None:
+            graph = self.make_breaking_graph(ancestors, break_on)
         return _mod_graph.LazyRevnoMapper(graph, tip, tip_revno)
 
     def test_init(self):
@@ -1375,5 +1377,5 @@
         self.assertEqual(4, mapper.get_dotted_revno('rev4'))
 
     def test_mainline_revision(self):
-        mapper = self.make_mapper(ancestry_1, 'rev4')
+        mapper = self.make_mapper(ancestry_1, 'rev4', break_on=['rev1'])
         self.assertEqual(3, mapper.get_dotted_revno('rev3'))



More information about the bazaar-commits mailing list