Rev 76: Found a buggy edge case. in http://bzr.arbash-meinel.com/plugins/history_db

John Arbash Meinel john at arbash-meinel.com
Fri Apr 9 21:17:16 BST 2010


At http://bzr.arbash-meinel.com/plugins/history_db

------------------------------------------------------------
revno: 76
revision-id: john at arbash-meinel.com-20100409201700-zbzif7j6gaqsn9b4
parent: john at arbash-meinel.com-20100409195807-21yviuv01nps0od1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: history_db
timestamp: Fri 2010-04-09 15:17:00 -0500
message:
  Found a buggy edge case.
  
  If we just created a new dotted revno, and then tried to _step_to_latest
  on that branch, we would fail to notice that we already knew about that
  revno. Causing us to walk the whole mainline too many times.
-------------- next part --------------
=== modified file 'history_db.py'
--- a/history_db.py	2010-04-09 19:58:07 +0000
+++ b/history_db.py	2010-04-09 20:17:00 +0000
@@ -990,6 +990,8 @@
         :return: None
         """
         self._stats['step to latest'] += 1
+        step_count = 0
+        start_point = self._imported_mainline_id
         while self._imported_mainline_id is not None:
             if (base_revno,) in self._known_dotted:
                 # We have walked far enough to load the original revision,
@@ -1008,6 +1010,10 @@
             if base_revno == 0:
                 self._stats['step mainline to-latest NULL'] += 1
             self._step_mainline()
+            step_count += 1
+        if step_count > 10:
+            import pdb; pdb.set_trace()
+            trace.note('stepped %d for %d' % (step_count, base_revno))
 
     def _pop_node(self):
         """Move the last node from the _depth_first_stack to _scheduled_stack.
@@ -1092,6 +1098,7 @@
         node.end_of_merge = end_of_merge
         self._imported_dotted_revno[node.key] = static_tuple.StaticTuple(
             revno, end_of_merge, node.merge_depth)
+        self._known_dotted.add(revno)
         node._pending_parents = None
         self._scheduled_stack.append(node)
 
@@ -1099,9 +1106,9 @@
         self._depth_first_stack = []
         self._scheduled_stack = []
         self._seen_parents = set()
-        ## if not self._mainline_db_ids:
-        ##     # Nothing to number
-        ##     return
+        if not self._mainline_db_ids:
+            # Nothing to number
+            return
         self._push_node(self._mainline_db_ids[0], 0)
 
         while self._depth_first_stack:

=== modified file 'test_importer.py'
--- a/test_importer.py	2010-04-09 19:58:07 +0000
+++ b/test_importer.py	2010-04-09 20:17:00 +0000
@@ -670,3 +670,11 @@
                           (self.F_id, (1, 1, 3), False, 1),
                           (self.G_id, (4,), False, 0),
                          ])
+        self.assertTrue(self.E_id in inc_merger._imported_dotted_revno)
+        self.assertTrue((1,1,2) in inc_merger._known_dotted)
+
+    def test_handles_already_imported(self):
+        b = self.make_interesting_branch()
+        inc_merger = self.make_inc_merger(b, 'O', 'O')
+        inc_merger.topo_order()
+        self.assertScheduledStack(inc_merger, [])



More information about the bazaar-commits mailing list