Rev 4497: When checking that a key prefix is present/missing in http://bazaar.launchpad.net/~jameinel/bzr/1.17-chk-multilevel

John Arbash Meinel john at arbash-meinel.com
Fri Jun 26 20:01:06 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.17-chk-multilevel

------------------------------------------------------------
revno: 4497
revision-id: john at arbash-meinel.com-20090626190038-od1qd6psjqoco61a
parent: john at arbash-meinel.com-20090626184906-9ex313bwy3xmssi1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-chk-multilevel
timestamp: Fri 2009-06-26 14:00:38 -0500
message:
  When checking that a key prefix is present/missing
  we need to search all possible prefixes on both sides.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-06-26 18:49:06 +0000
+++ b/bzrlib/chk_map.py	2009-06-26 19:00:38 +0000
@@ -1516,9 +1516,13 @@
         # items, so we can queue up the uninteresting stuff, knowing that we've
         # handled the interesting ones
         for prefix, ref in uninteresting_chks_to_enqueue:
-            if prefix not in interesting_prefixes:
-                # Keys with this prefix was not interesting from any of the
-                # interesting roots.
+            not_interesting = True
+            for i in xrange(len(prefix), 0, -1):
+                if prefix[:i] in interesting_prefixes:
+                    not_interesting = False
+                    break
+            if not_interesting:
+                # This prefix is not part of the remaining 'interesting set'
                 continue
             heapq.heappush(self._uninteresting_queue, (prefix, None, ref))
 

=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2009-06-25 21:04:43 +0000
+++ b/bzrlib/tests/test_chk_map.py	2009-06-26 19:00:38 +0000
@@ -2187,6 +2187,8 @@
         c_map._dump_tree() # load everything
         key1 = c_map.key()
         key1_a = c_map._root_node._items['a'].key()
+        key1_c = c_map._root_node._items['c'].key()
+        key1_d = c_map._root_node._items['d'].key()
 
         c_map2 = self.make_one_deep_two_prefix_map(chk_map._search_key_plain)
         c_map2._dump_tree()
@@ -2197,13 +2199,22 @@
         iterator = self.get_iterator([key2], [key1], chk_map._search_key_plain)
         root_results = [record.key for record in iterator._read_all_roots()]
         self.assertEqual([key2], root_results)
-        c_map = self.make_two_deep_map()
         # Only the 'a' subset should be queued up, since 'c' and 'd' cannot be
         # present
         self.assertEqual([('a', None, key1_a)], iterator._uninteresting_queue)
         self.assertEqual([('aa', None, key2_aa), ('ad', None, key2_ad)],
                          iterator._interesting_queue)
 
+        iterator = self.get_iterator([key1], [key2], chk_map._search_key_plain)
+        root_results = [record.key for record in iterator._read_all_roots()]
+        self.assertEqual([key1], root_results)
+
+        self.assertEqual([('aa', None, key2_aa), ('ad', None, key2_ad)],
+                         iterator._uninteresting_queue)
+        self.assertEqual([('a', None, key1_a), ('c', None, key1_c),
+                          ('d', None, key1_d),
+                         ], iterator._interesting_queue)
+
     def test__read_all_roots_yields_extra_deep_records(self):
         # This is a bit more controversial, and potentially a problem for
         # stacking in very extreme circumstances. (it should be okay, because



More information about the bazaar-commits mailing list