867
867
self._chk_id_roots = None
868
868
self._chk_p_id_roots = None
870
def _get_filtered_inv_stream(self):
870
def _get_inventory_stream(self, inventory_keys):
871
871
"""Get a stream of inventory texts.
873
873
When this function returns, self._chk_id_roots and self._chk_p_id_roots
879
879
id_roots_set = set()
880
880
p_id_roots_set = set()
881
881
source_vf = self.from_repository.inventories
882
stream = source_vf.get_record_stream(self._revision_keys,
882
stream = source_vf.get_record_stream(inventory_keys,
883
883
'groupcompress', True)
884
884
for record in stream:
885
885
bytes = record.get_bytes_as('fulltext')
949
949
for stream_info in self._fetch_revision_texts(revision_ids):
950
950
yield stream_info
951
951
self._revision_keys = [(rev_id,) for rev_id in revision_ids]
952
yield self._get_filtered_inv_stream()
952
yield self._get_inventory_stream(self._revision_keys)
953
953
# The keys to exclude are part of the search recipe
954
954
_, _, exclude_keys, _ = search.get_recipe()
955
955
for stream_info in self._get_filtered_chk_streams(exclude_keys):
956
956
yield stream_info
957
957
yield self._get_text_stream()
959
def get_stream_for_missing_keys(self, missing_keys):
960
# missing keys can only occur when we are byte copying and not
961
# translating (because translation means we don't send
962
# unreconstructable deltas ever).
964
keys['texts'] = set()
965
keys['revisions'] = set()
966
keys['inventories'] = set()
967
keys['chk_bytes'] = set()
968
keys['signatures'] = set()
969
for key in missing_keys:
970
keys[key[0]].add(key[1:])
971
if len(keys['revisions']):
972
# If we allowed copying revisions at this point, we could end up
973
# copying a revision without copying its required texts: a
974
# violation of the requirements for repository integrity.
975
raise AssertionError(
976
'cannot copy revisions to fill in missing deltas %s' % (
978
for substream_kind in ['texts', 'chk_bytes', 'signatures']:
979
if len(keys[substream_kind]) > 0:
980
raise AssertionError('The only missing keys we should'
981
' be filling in are inventory keys, not %s'
983
# Yield the inventory stream, so we can find the chk stream
984
yield self._get_inventory_stream(keys['inventories'])
985
# We use the empty set for excluded_keys, to make it clear that we want
986
# to transmit all referenced chk pages.
987
for stream_info in self._get_filtered_chk_streams(set()):
960
991
class RepositoryFormatCHK1(RepositoryFormatPack):
961
992
"""A hashed CHK+group compress pack repository."""