655
def insert_data_stream(self, (format, data_list, reader_callable)):
656
"""Insert knit records from a data stream into this knit.
658
Existing versions will be ...
660
:seealso: get_data_stream
662
if format != self.get_format_signature():
663
raise KnitDataStreamIncompatible(
664
format, self.get_format_signature())
665
for version_id, options, length, parents in data_list:
666
# do we have this version_id:
667
# * yes: consistency check
668
# * no: plan to insert it
669
raw_data = reader_callable(length)
670
if self.has_version(version_id):
671
# Make sure that if we've already seen this version_id, that it has
673
# First, check the list of parents.
674
my_parents = self.get_parents_with_ghosts(version_id)
675
if my_parents != parents:
678
'parents list %r from data stream does not match '
679
'already recorded parents %r for %s'
680
% (parents, my_parents, version_id))
682
# Also check the SHA-1 of the fulltext this content will
684
my_fulltext_sha1 = self.get_sha1(version_id)
685
df, rec = self._data._parse_record_header(version_id, raw_data)
686
stream_fulltext_sha1 = rec[3]
687
if my_fulltext_sha1 != stream_fulltext_sha1:
688
# Actually, we don't know if it's this knit that's corrupt,
689
# or the data stream we're trying to insert.
691
self.filename, 'sha-1 does not match %s' % version_id)
693
# We don't have this record. Insert it.
694
self._add_raw_records([(version_id, options, parents, length)], raw_data)
654
696
def versions(self):
655
697
"""See VersionedFile.versions."""
656
698
return self._index.get_versions()