738
def iter_files_bytes(self, desired_files):
739
"""Iterate through file versions.
741
Files will not necessarily be returned in the order they occur in
742
desired_files. No specific order is guaranteed.
744
Yields pairs of identifier, bytes_iterator. identifier is an opaque
745
value supplied by the caller as part of desired_files. It should
746
uniquely identify the file version in the caller's context. (Examples:
747
an index number or a TreeTransform trans_id.)
749
bytes_iterator is an iterable of bytestrings for the file. The
750
kind of iterable and length of the bytestrings are unspecified, but for
751
this implementation, it is a list of lines produced by
752
VersionedFile.get_lines().
754
:param desired_files: a list of (file_id, revision_id, identifier)
757
transaction = self.get_transaction()
758
for file_id, revision_id, callable_data in desired_files:
760
weave = self.weave_store.get_weave(file_id, transaction)
761
except errors.NoSuchFile:
762
raise errors.NoSuchIdInRepository(self, file_id)
763
yield callable_data, weave.get_lines(revision_id)
765
def item_keys_introduced_by(self, revision_ids, _files_pb=None):
766
"""Get an iterable listing the keys of all the data introduced by a set
769
The keys will be ordered so that the corresponding items can be safely
770
fetched and inserted in that order.
772
:returns: An iterable producing tuples of (knit-kind, file-id,
773
versions). knit-kind is one of 'file', 'inventory', 'signatures',
774
'revisions'. file-id is None unless knit-kind is 'file'.
776
# XXX: it's a bit weird to control the inventory weave caching in this
777
# generator. Ideally the caching would be done in fetch.py I think. Or
778
# maybe this generator should explicitly have the contract that it
779
# should not be iterated until the previously yielded item has been
781
inv_w = self.get_inventory_weave()
784
# file ids that changed
785
file_ids = self.fileids_altered_by_revision_ids(revision_ids)
787
num_file_ids = len(file_ids)
788
for file_id, altered_versions in file_ids.iteritems():
789
if _files_pb is not None:
790
_files_pb.update("fetch texts", count, num_file_ids)
792
yield ("file", file_id, altered_versions)
793
# We're done with the files_pb. Note that it finished by the caller,
794
# just as it was created by the caller.
798
yield ("inventory", None, revision_ids)
802
revisions_with_signatures = set()
803
for rev_id in revision_ids:
805
self.get_signature_text(rev_id)
806
except errors.NoSuchRevision:
810
revisions_with_signatures.add(rev_id)
811
yield ("signatures", None, revisions_with_signatures)
814
yield ("revisions", None, revision_ids)
736
817
def get_inventory_weave(self):
737
818
return self.control_weaves.get_weave('inventory',