Rev 4674: Catch a corner case that we were missing. in http://bazaar.launchpad.net/~jameinel/bzr/2.0.1-faster-log-dir-bug374730

John Arbash Meinel john at arbash-meinel.com
Thu Sep 24 20:26:59 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.0.1-faster-log-dir-bug374730

------------------------------------------------------------
revno: 4674
revision-id: john at arbash-meinel.com-20090924192645-hyy1ycnnk6u3j5j6
parent: john at arbash-meinel.com-20090924185141-3gofyxyrmw276rjm
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0.1-faster-log-dir-bug374730
timestamp: Thu 2009-09-24 14:26:45 -0500
message:
  Catch a corner case that we were missing.
  The CHKInventory tests were passing, but failed for test_inv because
  we were passing None to _getitems(). That only failed for InternalNodes,
  but we were using a structure that didn't have internal nodes.
  So now the test is parameterized on a small CHKInventory page size
  to force those things out into the open.
-------------- next part --------------
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2009-09-24 18:51:41 +0000
+++ b/bzrlib/inventory.py	2009-09-24 19:26:45 +0000
@@ -1576,9 +1576,7 @@
             foo-id, baz-id, frob-id, fringle-id
         As interesting ids.
         """
-        # When we hit the TREE_ROOT, we'll get an interesting parent of None,
-        # but we don't actually want to recurse into that
-        interesting = set([None])
+        interesting = set()
         # TODO: Pre-pass over the list of fileids to see if anything is already
         #       deserialized in self._fileid_to_entry_cache
 
@@ -1596,7 +1594,13 @@
         # parents of those parents. It also may have some duplicates with
         # specific_fileids
         remaining_parents = interesting.difference(file_ids)
+        # When we hit the TREE_ROOT, we'll get an interesting parent of None,
+        # but we don't actually want to recurse into that
+        interesting.add(None) # this will auto-filter it in the loop
+        remaining_parents.discard(None) 
         while remaining_parents:
+            if None in remaining_parents:
+                import pdb; pdb.set_trace()
             next_parents = set()
             for entry in self._getitems(remaining_parents):
                 next_parents.add(entry.parent_id)
@@ -1606,8 +1610,8 @@
             remaining_parents = next_parents.difference(interesting)
             interesting.update(remaining_parents)
             # We should probably also .difference(directories_to_expand)
+        interesting.update(file_ids)
         interesting.discard(None)
-        interesting.update(file_ids)
         while directories_to_expand:
             # Expand directories by looking in the
             # parent_id_basename_to_file_id map
@@ -1636,9 +1640,6 @@
          parent_to_children) = self._expand_fileids_to_parents_and_children(
                                 specific_fileids)
         entries = self.iter_entries()
-        # TODO: ???
-        # if self.root is None:
-        return Inventory(root_id=None)
         other = Inventory(entries.next()[1].file_id)
         other.root.revision = self.root.revision
         other.revision_id = self.revision_id

=== modified file 'bzrlib/tests/test_inv.py'
--- a/bzrlib/tests/test_inv.py	2009-09-24 18:51:41 +0000
+++ b/bzrlib/tests/test_inv.py	2009-09-24 19:26:45 +0000
@@ -1254,7 +1254,10 @@
         self.make_file(inv, 'subsub-file1', 'sub-dir1-id')
         self.make_file(inv, 'sub2-file1', 'dir2-id')
         chk_bytes = self.get_chk_bytes()
-        chk_inv = CHKInventory.from_inventory(chk_bytes, inv)
+        #  use a small maximum_size to force internal paging structures
+        chk_inv = CHKInventory.from_inventory(chk_bytes, inv,
+                        maximum_size=100,
+                        search_key_name='hash-255-way')
         bytes = ''.join(chk_inv.to_lines())
         return CHKInventory.deserialise(chk_bytes, bytes, ("revid",))
 
@@ -1323,3 +1326,23 @@
         self.assertExpand(['TREE_ROOT', 'dir1-id', 'sub-dir1-id',
                            'sub-file1-id', 'sub-file2-id', 'subsub-file1-id',
                           ], inv, ['dir1-id'])
+
+    def test_from_root(self):
+        inv = self.make_simple_inventory()
+        self.assertExpand(['TREE_ROOT', 'dir1-id', 'dir2-id', 'sub-dir1-id',
+                           'sub-file1-id', 'sub-file2-id', 'sub2-file1-id',
+                           'subsub-file1-id', 'top-id'], inv, ['TREE_ROOT'])
+
+    def test_top_level_file(self):
+        inv = self.make_simple_inventory()
+        self.assertExpand(['TREE_ROOT', 'top-id'], inv, ['top-id'])
+
+    def test_subsub_file(self):
+        inv = self.make_simple_inventory()
+        self.assertExpand(['TREE_ROOT', 'dir1-id', 'sub-dir1-id',
+                           'subsub-file1-id'], inv, ['subsub-file1-id'])
+
+    def test_sub_and_root(self):
+        inv = self.make_simple_inventory()
+        self.assertExpand(['TREE_ROOT', 'dir1-id', 'sub-dir1-id', 'top-id',
+                           'subsub-file1-id'], inv, ['top-id', 'subsub-file1-id'])



More information about the bazaar-commits mailing list