Rev 2804: Add pack objects to the api for PackCollection.create_pack_from_packs. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Wed Oct 10 08:31:40 BST 2007


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

------------------------------------------------------------
revno: 2804
revision-id: robertc at robertcollins.net-20071010073131-8iiuanh7s960lyim
parent: robertc at robertcollins.net-20071010064636-gepsfmu4dkpfyodk
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Wed 2007-10-10 17:31:31 +1000
message:
  Add pack objects to the api for PackCollection.create_pack_from_packs.
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-10-10 06:46:36 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-10-10 07:31:31 +0000
@@ -242,10 +242,8 @@
         # determine which packs need changing
         pack_distribution = self.pack_distribution(total_revisions)
         existing_packs = []
-        for index, transport_and_name in self.repo._revision_pack_map.iteritems():
-            if index is None:
-                continue
-            revision_count = index.key_count()
+        for pack in self.all_packs():
+            revision_count = pack.get_revision_count()
             if revision_count == 0:
                 # revision less packs are not generated by normal operation,
                 # only by operations like sign-my-commits, and thus will not
@@ -258,15 +256,16 @@
                 # one revision for each to the total revision count, to get
                 # a matching distribution.
                 continue
-            existing_packs.append((revision_count, transport_and_name,
-                self.get_pack_by_name(transport_and_name[1])))
+            existing_packs.append((revision_count, self._pack_tuple(pack.name),
+                pack))
         pack_operations = self.plan_autopack_combinations(
             existing_packs, pack_distribution)
         self._execute_pack_operations(pack_operations)
         return True
 
-    def create_pack_from_packs(self, revision_index_map, inventory_index_map,
-        text_index_map, signature_index_map, suffix, revision_ids=None):
+    def create_pack_from_packs(self, packs, revision_index_map,
+        inventory_index_map, text_index_map, signature_index_map, suffix,
+        revision_ids=None):
         """Create a new pack by reading data from other packs.
 
         This does little more than a bulk copy of data. One key difference
@@ -275,6 +274,7 @@
         along with its indices, and the name added to the pack names. The 
         source packs are not altered.
 
+        :param packs: An iterable of Packs to combine.
         :param revision_index_map: A revision index map.
         :param inventory_index_map: A inventory index map.
         :param text_index_map: A text index map.
@@ -521,13 +521,11 @@
             # determine which packs need changing
             pack_distribution = [1]
             pack_operations = [[0, []]]
-            for index, transport_and_name in self.repo._revision_pack_map.iteritems():
-                if index is None:
-                    continue
-                revision_count = index.key_count()
+            for pack in self.all_packs():
+                revision_count = pack.get_revision_count()
                 pack_operations[-1][0] += revision_count
-                pack_operations[-1][1].append((transport_and_name,
-                    self.get_pack_by_name(transport_and_name[1])))
+                pack_operations[-1][1].append((self._pack_tuple(pack.name),
+                    pack))
             self._execute_pack_operations(pack_operations)
         finally:
             if not self.repo.is_in_write_group():
@@ -595,7 +593,7 @@
         text_index_map = self._text_index_map(pack_details)
         # select signature keys
         signature_index_map = self._signature_index_map(pack_details)
-        self.create_pack_from_packs(revision_index_map, inv_index_map,
+        self.create_pack_from_packs(packs, revision_index_map, inv_index_map,
             text_index_map, signature_index_map, '.autopack')
 
     def _copy_nodes(self, nodes, index_map, writer, write_index):
@@ -711,7 +709,7 @@
             sig_index = self._make_index(name, '.six')
             result = Pack(self._pack_transport, name, rev_index, inv_index,
                 txt_index, sig_index)
-            self._packs[name] = result
+            self.add_pack_to_memory(result)
             return result
 
     def allocate(self, name, revision_index_length, inventory_index_length,
@@ -839,7 +837,7 @@
         self.ensure_loaded()
         for transport, name in pack_details:
             index_name = name[:-5] + index_suffix
-            new_index = self._make_index(index_name, index_suffix)
+            new_index = self._make_index(name[:-5], index_suffix)
             indices.append(new_index)
             pack_map[new_index] = (transport, name)
         return pack_map, indices
@@ -1325,7 +1323,8 @@
             # - clearly we need a remove_index call too.
             del self.repo._inv_all_indices._indices[1]
             self.repo._inv_knit_access.set_writer(None, None, (None, None))
-        self.repo._inv_pack_map = None
+        else:
+            self.repo._inv_pack_map = None
         return inv_index, inventory_index_length
 
     def get_weave(self):

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-10-10 05:48:02 +0000
+++ b/bzrlib/repository.py	2007-10-10 07:31:31 +0000
@@ -2349,6 +2349,7 @@
         text_index_map = self.source._packs._text_index_map(packs)
         signature_index_map = self.source._packs._signature_index_map(packs)
         pack = self.target._packs.create_pack_from_packs(
+            _packs,
             revision_index_map,
             inventory_index_map,
             text_index_map,



More information about the bazaar-commits mailing list