Rev 5119: Pass in the reload function, and ensure it gets passed down the stack. in http://bazaar.launchpad.net/~jameinel/bzr/2.2.0b2-pack-collection

John Arbash Meinel john at arbash-meinel.com
Wed Jun 16 17:05:49 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.2.0b2-pack-collection

------------------------------------------------------------
revno: 5119
revision-id: john at arbash-meinel.com-20100616160540-qdkfkn8hkfitg5f8
parent: john at arbash-meinel.com-20100616155647-g3icr115x7k1ry0h
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.2.0b2-pack-collection
timestamp: Wed 2010-06-16 11:05:40 -0500
message:
  Pass in the reload function, and ensure it gets passed down the stack.
-------------- next part --------------
=== modified file 'bzrlib/pack_collection.py'
--- a/bzrlib/pack_collection.py	2010-06-16 15:56:47 +0000
+++ b/bzrlib/pack_collection.py	2010-06-16 16:05:40 +0000
@@ -576,11 +576,11 @@
     def _aggregate_indexes_from_pack(self, pack, writable=False):
         """Add the indexes in pack to the aggregate indexes."""
         for index_name, index in pack.get_indexes().iteritems():
-            # TODO: should we be stricter that all pack files have identical
-            #       indexes?
+            # Note: We are not strict that all pack files have an identical set
+            #       of indices.
             if index_name not in self._aggregate_indexes:
-                # TODO: need to handle reload_func and flush_func
-                agg_index = AggregateIndex()
+                # TODO: need to handle flush_func
+                agg_index = AggregateIndex(reload_func=self.memo_tracker.reload)
                 self._aggregate_indexes[index_name] = agg_index
             else:
                 agg_index = self._aggregate_indexes[index_name]

=== modified file 'bzrlib/tests/test_pack_collection.py'
--- a/bzrlib/tests/test_pack_collection.py	2010-06-16 15:56:47 +0000
+++ b/bzrlib/tests/test_pack_collection.py	2010-06-16 16:05:40 +0000
@@ -478,3 +478,12 @@
         self.assertEqual(['t_index'], sorted(collection._aggregate_indexes))
         agg_index = collection._aggregate_indexes['t_index']
         self.assertEqual(0, len(agg_index.combined_index._indices))
+
+    def test__aggregate_indexes_get_reload_func(self):
+        collection = self.make_collection()
+        memo = bencode.bencode({'t_index': (1024,)})
+        collection.memo_tracker.add_memo('t-pack', memo)
+        agg_index = collection._aggregate_indexes['t_index']
+        self.assertEqual(collection.memo_tracker.reload, agg_index._reload_func)
+        self.assertEqual(collection.memo_tracker.reload,
+                         agg_index.combined_index._reload_func)



More information about the bazaar-commits mailing list