Rev 3812: Insert a single stream with all inventories being fetched, not one per inventory. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Tue Feb 10 22:54:48 GMT 2009


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

------------------------------------------------------------
revno: 3812
revision-id: robertc at robertcollins.net-20090210225446-5vc8llbvwnxpbkp5
parent: robertc at robertcollins.net-20090210040550-r6r00iuvekq26wxe
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Wed 2009-02-11 09:54:46 +1100
message:
  Insert a single stream with all inventories being fetched, not one per inventory.
=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py	2009-02-10 04:05:50 +0000
+++ b/bzrlib/fetch.py	2009-02-10 22:54:46 +0000
@@ -310,21 +310,23 @@
             True) # We need them as full-texts so we can find their references
         uninteresting_chk_roots = set()
         interesting_chk_roots = set()
-        for record in inv_stream:
-            bytes = record.get_bytes_as('fulltext')
-            chk_inv = inventory.CHKInventory.deserialise(
-                self.from_repository.chk_bytes, bytes, record.key)
-            if record.key == start_rev_key:
-                uninteresting_chk_roots.add(chk_inv.id_to_entry.key())
-                p_id_map = chk_inv.parent_id_basename_to_file_id
-                if p_id_map is not None:
-                    uninteresting_chk_roots.add(p_id_map.key())
-            else:
-                self.to_repository.inventories.insert_record_stream([record])
-                interesting_chk_roots.add(chk_inv.id_to_entry.key())
-                p_id_map = chk_inv.parent_id_basename_to_file_id
-                if p_id_map is not None:
-                    interesting_chk_roots.add(p_id_map.key())
+        def filter_inv_stream(inv_stream):
+            for record in inv_stream:
+                bytes = record.get_bytes_as('fulltext')
+                chk_inv = inventory.CHKInventory.deserialise(
+                    self.from_repository.chk_bytes, bytes, record.key)
+                if record.key == start_rev_key:
+                    uninteresting_chk_roots.add(chk_inv.id_to_entry.key())
+                    p_id_map = chk_inv.parent_id_basename_to_file_id
+                    if p_id_map is not None:
+                        uninteresting_chk_roots.add(p_id_map.key())
+                else:
+                    yield record
+                    interesting_chk_roots.add(chk_inv.id_to_entry.key())
+                    p_id_map = chk_inv.parent_id_basename_to_file_id
+                    if p_id_map is not None:
+                        interesting_chk_roots.add(p_id_map.key())
+        self.to_repository.inventories.insert_record_stream(filter_inv_stream(inv_stream))
         # Now that we have worked out all of the interesting root nodes, grab
         # all of the interesting pages and insert them
         interesting = chk_map.iter_interesting_nodes(




More information about the bazaar-commits mailing list