Rev 54: Handle an edge case when setting the end-of-merge info. in http://bzr.arbash-meinel.com/plugins/history_db

John Arbash Meinel john at arbash-meinel.com
Wed Apr 7 17:51:38 BST 2010


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

------------------------------------------------------------
revno: 54
revision-id: john at arbash-meinel.com-20100407165123-4xtc83jnxid0q9yn
parent: john at arbash-meinel.com-20100407164722-9obvhf939r5nfw58
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: history_db
timestamp: Wed 2010-04-07 11:51:23 -0500
message:
  Handle an edge case when setting the end-of-merge info.
-------------- next part --------------
=== modified file 'history_db.py'
--- a/history_db.py	2010-04-07 16:47:22 +0000
+++ b/history_db.py	2010-04-07 16:51:23 +0000
@@ -838,13 +838,13 @@
                 revno = (1,)
             else:
                 revno = (0, branch_count, 1)
-        # XXX: This isn't correct any more, we need to look at the parent,
-        #      what *would* have been scheduled if we weren't doing partial
-        #      scheduling. Then again, maybe it is correct for all but the
-        #      mainline (first entry on the stack). Because we always break
-        #      apart the dotted_revno cache based on what has gotten merged...
         if not self._scheduled_stack:
+            # For all but mainline revisions, we break on the end-of-merge. So
+            # when we start new numbering, end_of_merge is True. For mainline
+            # revisions, this is only true when we don't have a parent.
             end_of_merge = True
+            if left_parent_id is not None and merge_depth == 0:
+                end_of_merge = False
         else:
             prev_db_id, prev_revno, _, prev_depth = self._scheduled_stack[-1]
             if prev_depth < merge_depth:
@@ -891,6 +891,8 @@
 
     def do_import(self):
         self._find_interesting_ancestry()
+        self._update_info_from_dotted_revno()
+        self._compute_merge_sort()
 
 
 class Querier(object):

=== modified file 'test_importer.py'
--- a/test_importer.py	2010-04-07 16:47:22 +0000
+++ b/test_importer.py	2010-04-07 16:51:23 +0000
@@ -416,3 +416,17 @@
                           (self.M_id, (1, 2, 5), False, 1),
                           (self.O_id, (6,), False, 0),
                          ], inc_importer._scheduled_stack)
+
+    def test__incremental_merge_sort_handles_simple_child(self):
+        ancestry = {'A': (), 'B': ('A',)}
+        b = MockBranch(ancestry, 'A')
+        importer = history_db.Importer(':memory:', b, incremental=False)
+        importer.do_import()
+        importer._update_ancestry('B')
+        self.grab_interesting_ids(importer._rev_id_to_db_id)
+        inc_importer = history_db._IncrementalImporter(importer, self.B_id)
+        inc_importer._find_interesting_ancestry()
+        inc_importer._update_info_from_dotted_revno()
+        inc_importer._compute_merge_sort()
+        self.assertEqual([(self.B_id, (2,), False, 0),
+                         ], inc_importer._scheduled_stack)



More information about the bazaar-commits mailing list