709
710
def __init__(self, index, data_access, max_delta_chain=200,
711
annotated=False, reload_func=None):
711
712
"""Create a KnitVersionedFiles with index and data_access.
713
714
:param index: The index for the knit data.
717
718
insertion. Set to 0 to prohibit the use of deltas.
718
719
:param annotated: Set to True to cause annotations to be calculated and
719
720
stored during insertion.
721
:param reload_func: An function that can be called if we think we need
722
to reload the pack listing and try again. See
723
'bzrlib.repofmt.pack_repo.AggregateIndex' for the signature.
721
725
self._index = index
722
726
self._access = data_access
1159
1164
if not self._index.has_graph:
1160
1165
# Cannot topological order when no graph has been stored.
1161
1166
ordering = 'unordered'
1168
remaining_keys = keys
1171
keys = set(remaining_keys)
1172
for content_factory in self._get_remaining_record_stream(keys,
1173
ordering, include_delta_closure):
1174
remaining_keys.discard(content_factory.key)
1175
yield content_factory
1177
except errors.RetryWithNewPacks, e:
1181
def _get_remaining_record_stream(self, keys, ordering,
1182
include_delta_closure):
1162
1183
if include_delta_closure:
1163
1184
positions = self._get_components_positions(keys, allow_missing=True)
2433
2454
if current_index is not None:
2434
2455
request_lists.append((current_index, current_list))
2435
2456
for index, offsets in request_lists:
2436
transport, path = self._indices[index]
2437
reader = pack.make_readv_reader(transport, path, offsets)
2438
for names, read_func in reader.iter_records():
2439
yield read_func(None)
2458
transport, path = self._indices[index]
2460
# A KeyError here indicates that someone has triggered an index
2461
# reload, and this index has gone missing, we need to start
2463
raise errors.RetryWithNewPacks(reload_occurred=True,
2464
exc_info=sys.exc_info())
2466
reader = pack.make_readv_reader(transport, path, offsets)
2467
for names, read_func in reader.iter_records():
2468
yield read_func(None)
2469
except errors.NoSuchFile:
2470
# A NoSuchFile error indicates that a pack file has gone
2471
# missing on disk, we need to trigger a reload, and start over.
2472
raise errors.RetryWithNewPacks(reload_occurred=False,
2473
exc_info=sys.exc_info())
2441
2475
def set_writer(self, writer, index, transport_packname):
2442
2476
"""Set a writer to use for adding data."""