Rev 3853: Fix the file_id versus file_id_key confusion in CHKInventoryDirectory.children() in http://bzr.arbash-meinel.com/branches/bzr/brisbane/core

John Arbash Meinel john at arbash-meinel.com
Fri Mar 6 21:19:16 GMT 2009


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/core

------------------------------------------------------------
revno: 3853
revision-id: john at arbash-meinel.com-20090306211910-lk7175p9cmvlmgbs
parent: john at arbash-meinel.com-20090306202652-r9nwjvoqc5zs64h3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: brisbane-core
timestamp: Fri 2009-03-06 15:19:10 -0600
message:
  Fix the file_id versus file_id_key confusion in CHKInventoryDirectory.children()
-------------- next part --------------
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2009-03-06 05:27:42 +0000
+++ b/bzrlib/inventory.py	2009-03-06 21:19:10 +0000
@@ -1854,36 +1854,29 @@
         """
         if self._children is not None:
             return self._children
-        if self._chk_inventory.parent_id_basename_to_file_id is None:
-            # Slow path - read the entire inventory looking for kids.
-            result = {}
-            for file_id, bytes in self._chk_inventory.id_to_entry.iteritems():
-                entry = self._chk_inventory._bytes_to_entry(bytes)
-                if entry.parent_id == self.file_id:
-                    result[entry.name] = entry
-            self._children = result
-            return result
+        # No longer supported
+        assert self._chk_inventory.parent_id_basename_to_file_id is not None
         result = {}
         # XXX: Todo - use proxy objects for the children rather than loading
         # all when the attribute is referenced.
         parent_id_index = self._chk_inventory.parent_id_basename_to_file_id
-        child_ids = set()
+        child_keys = set()
         for (parent_id, name_utf8), file_id in parent_id_index.iteritems(
             key_filter=[(self.file_id,)]):
-            child_ids.add((file_id,))
+            child_keys.add((file_id,))
         cached = set()
-        for file_id in child_ids:
-            entry = self._chk_inventory._entry_cache.get(file_id, None)
+        for file_id_key in child_keys:
+            entry = self._chk_inventory._entry_cache.get(file_id_key[0], None)
             if entry is not None:
                 result[entry.name] = entry
-                cached.add(file_id)
-        child_ids.difference_update(cached)
+                cached.add(file_id_key)
+        child_keys.difference_update(cached)
         # populate; todo: do by name
         id_to_entry = self._chk_inventory.id_to_entry
-        for file_id, bytes in id_to_entry.iteritems(child_ids):
+        for file_id_key, bytes in id_to_entry.iteritems(child_keys):
             entry = self._chk_inventory._bytes_to_entry(bytes)
             result[entry.name] = entry
-            self._chk_inventory._entry_cache[file_id] = entry
+            self._chk_inventory._entry_cache[file_id_key[0]] = entry
         self._children = result
         return result
 



More information about the bazaar-commits mailing list