Rev 2808: Eliminate the need to use a transport, name tuple to represent a pack during fetch. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Wed Oct 10 09:32:08 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2808
revision-id: robertc at robertcollins.net-20071010083158-zqmai921u4wiv28q
parent: robertc at robertcollins.net-20071010082447-qcfzqs11hk9l32tz
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Wed 2007-10-10 18:31:58 +1000
message:
Eliminate the need to use a transport,name tuple to represent a pack 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-10-10 08:24:47 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2007-10-10 08:31:58 +0000
@@ -267,20 +267,17 @@
self._execute_pack_operations(pack_operations)
return True
- def create_pack_from_packs(self, packs,
- signature_index_map, suffix,
- revision_ids=None):
+ def create_pack_from_packs(self, packs, 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
is that data with the same item key across multiple packs is elided
from the output. The new pack is written into the current pack store
along with its indices, and the name added to the pack names. The
- source packs are not altered.
+ source packs are not altered and are not required to be in the current
+ pack collection.
:param packs: An iterable of Packs to combine.
- :param text_index_map: A text index map.
- :param signature_index_map: A signature index map.
:param revision_ids: Either None, to copy all data, or a list
of revision_ids to limit the copied data to the data they
introduced.
@@ -407,6 +404,8 @@
time.time() - start_time)
# select signature keys
signature_filter = revision_keys # same keyspace
+ signature_index_map = self._packs_list_to_pack_map_and_index_list(
+ packs, 'signature_index')[0]
signature_nodes = self._index_contents(signature_index_map,
signature_filter)
# copy signature keys and adjust values
@@ -501,7 +500,7 @@
pack_details = [details for details,_ in pack_list]
packs = [pack for _, pack in pack_list]
assert pack_details[0].__class__ == tuple
- self._combine_packs(pack_details, packs)
+ self.create_pack_from_packs(packs, '.autopack')
for pack_detail in pack_details:
self._remove_pack_by_name(pack_detail[1])
# record the newly available packs and stop advertising the old
@@ -582,24 +581,6 @@
return pack_operations
- def _combine_packs(self, pack_details, packs):
- """Combine the data from the packs listed in pack_details.
-
- This does little more than a bulk copy of data. One key difference
- is that data with the same item key across multiple packs is elided
- from the output. The new pack is written into the current pack store
- along with its indices, and the name added to the pack names. The
- source packs are not altered.
-
- :param pack_details: A list of tuples with the transport and pack name
- in use.
- :return: None
- """
- # select signature keys
- signature_index_map = self._signature_index_map(pack_details)
- self.create_pack_from_packs(packs,
- signature_index_map, '.autopack')
-
def _copy_nodes(self, nodes, index_map, writer, write_index):
# plan a readv on each source pack:
# group by pack
@@ -744,6 +725,7 @@
objects, and pack_map is a mapping from those objects to the
pack tuple they describe.
"""
+ # TODO: stop using this; it creates new indices unnecessarily.
self.ensure_loaded()
details = []
for name in self.names():
@@ -864,10 +846,6 @@
pack_map[index] = (pack.transport, pack.file_name())
return pack_map, indices
- def _signature_index_map(self, pack_details):
- """Get a map of signature index -> packs for pack_details."""
- return self._make_index_to_pack_map(pack_details, '.six')[0]
-
def _index_contents(self, pack_map, key_filter=None):
"""Get an iterable of the index contents from a pack_map.
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-10-10 08:24:47 +0000
+++ b/bzrlib/repository.py 2007-10-10 08:31:58 +0000
@@ -2342,14 +2342,9 @@
revision_ids = self.missing_revision_ids(revision_id)
except errors.NoSuchRevision:
raise errors.InstallFailed([revision_id])
- packs = self.source._packs.all_pack_details()
- _packs = self.source._packs.all_packs()
- signature_index_map = self.source._packs._signature_index_map(packs)
+ packs = self.source._packs.all_packs()
pack = self.target._packs.create_pack_from_packs(
- _packs,
- signature_index_map,
- '.fetch',
- revision_ids,
+ packs, '.fetch', revision_ids,
)
if pack is not None:
self.target._packs._save_pack_names()
More information about the bazaar-commits
mailing list