Rev 2719: Steps toward filtering revisions/inventories/texts during fetch. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Thu Aug 16 10:40:46 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2719
revision-id: robertc at robertcollins.net-20070816094035-sng7y55hvkm5hg98
parent: robertc at robertcollins.net-20070906012636-43gj54nuooewzc3b
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Thu 2007-08-16 19:40:35 +1000
message:
  Steps toward filtering revisions/inventories/texts during fetch.
modified:
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2007-08-15 00:42:45 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-08-16 09:40:35 +0000
@@ -230,8 +230,12 @@
         inv_index = InMemoryGraphIndex(reference_lists=2)
         text_index = InMemoryGraphIndex(reference_lists=2, key_elements=2)
         signature_index = InMemoryGraphIndex(reference_lists=0)
-        # select revision keys
-        revision_nodes = self._index_contents(revision_index_map)
+        # select revisions
+        if revision_ids:
+            revision_keys = [(revision_id,) for revision_id in revision_ids]
+        else:
+            revision_keys = None
+        revision_nodes = self._index_contents(revision_index_map, revision_keys)
         # copy revision keys and adjust values
         self._copy_nodes_graph(revision_nodes, revision_index_map, writer, revision_index)
         if 'fetch' in debug.debug_flags:
@@ -240,7 +244,8 @@
                 len(list(revision_index.iter_all_entries())),
                 time.time() - start_time)
         # select inventory keys
-        inv_nodes = self._index_contents(inventory_index_map)
+        inv_keys = revision_keys # currently the same keyspace
+        inv_nodes = self._index_contents(inventory_index_map, inv_keys)
         # copy inventory keys and adjust values
         self._copy_nodes_graph(inv_nodes, inventory_index_map, writer, inv_index)
         if 'fetch' in debug.debug_flags:
@@ -641,11 +646,19 @@
                 (transport, name)
         return indices
 
-    def _index_contents(self, pack_map):
-        """Get an iterable of the index contents from a pack_map."""
+    def _index_contents(self, pack_map, key_filter=None):
+        """Get an iterable of the index contents from a pack_map.
+
+        :param pack_map: A map from indices to pack details.
+        :param key_filter: An optional filter to limit the
+            keys returned.
+        """
         indices = [index for index in pack_map.iterkeys()]
         all_index = CombinedGraphIndex(indices)
-        return all_index.iter_all_entries()
+        if key_filter is None:
+            return all_index.iter_all_entries()
+        else:
+            return all_index.iter_entries(key_filter)
 
     def save(self):
         builder = GraphIndexBuilder()

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-08-15 00:42:45 +0000
+++ b/bzrlib/repository.py	2007-08-16 09:40:35 +0000
@@ -1870,9 +1870,16 @@
             # TODO:
             # everything to do - use pack logic
             # to fetch from all packs to one without
-            # inventory parsing etc.
+            # inventory parsing etc, IFF nothing to be copied is in the target.
             # till then:
             revision_ids = self.source.all_revision_ids()
+            # implementing the TODO will involve:
+            # - detecting when all of a pack is selected
+            # - avoiding as much as possible pre-selection, so the
+            # more-core routines such as create_pack_from_packs can filter in
+            # a just-in-time fashion. (though having a HEADS list on a
+            # repository might make this a lot easier, because we could
+            # sensibly detect 'new revisions' without doing a full index scan.
         elif _mod_revision.is_null(revision_id):
             # nothing to do:
             return



More information about the bazaar-commits mailing list