~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Andrew Bennetts
  • Date: 2007-07-17 06:07:00 UTC
  • mto: (2535.4.4 streaming-smart-fetch)
  • mto: This revision was merged to the branch mainline in revision 2906.
  • Revision ID: andrew.bennetts@canonical.com-20070717060700-blzcnto7drjgc7yc
[broken] Closer to a working Repository.fetch_revisions smart request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
633
633
 
634
634
    def get_format_signature(self):
635
635
        """See VersionedFile.get_format_signature()."""
636
 
        if self.delta:
637
 
            delta_part = "delta"
638
 
        else:
639
 
            delta_part = "full"
 
636
#        if self.delta:
 
637
#            delta_part = "delta"
 
638
#        else:
 
639
#            delta_part = "full"
640
640
        if self.factory.annotated:
641
641
            annotated_part = "annotated"
642
642
        else:
643
643
            annotated_part = "plain"
644
 
        return "knit-%s-%s" % (delta_part, annotated_part)
 
644
        return "knit-%s" % (annotated_part,)
645
645
        
646
646
    def get_graph_with_ghosts(self):
647
647
        """See VersionedFile.get_graph_with_ghosts()."""
690
690
        :seealso: get_data_stream
691
691
        """
692
692
        if format != self.get_format_signature():
 
693
            mutter('incompatible format signature inserting to %r', self)
693
694
            raise KnitDataStreamIncompatible(
694
695
                format, self.get_format_signature())
 
696
 
 
697
        for version_id, options, length, parents in data_list:
 
698
            if self.has_version(version_id):
 
699
                # First check: the list of parents.
 
700
                my_parents = self.get_parents_with_ghosts(version_id)
 
701
                if my_parents != parents:
 
702
                    # XXX: KnitCorrupt is not quite the right exception here.
 
703
                    raise KnitCorrupt(
 
704
                        self.filename,
 
705
                        'parents list %r from data stream does not match '
 
706
                        'already recorded parents %r for %s'
 
707
                        % (parents, my_parents, version_id))
 
708
 
 
709
                # Also check the SHA-1 of the fulltext this content will
 
710
                # produce.
 
711
                raw_data = reader_callable(length)
 
712
                my_fulltext_sha1 = self.get_sha1(version_id)
 
713
                df, rec = self._data._parse_record_header(version_id, raw_data)
 
714
                stream_fulltext_sha1 = rec[3]
 
715
                if my_fulltext_sha1 != stream_fulltext_sha1:
 
716
                    # Actually, we don't know if it's this knit that's corrupt,
 
717
                    # or the data stream we're trying to insert.
 
718
                    raise KnitCorrupt(
 
719
                        self.filename, 'sha-1 does not match %s' % version_id)
 
720
            else:
 
721
                self._add_raw_records(
 
722
                    [(version_id, options, parents, length)],
 
723
                    reader_callable(length))
 
724
        return
 
725
 
 
726
 
 
727
 
 
728
 
 
729
 
695
730
        # To avoid lots of small writes (and small reads from the
696
731
        # reader_callable), we batch up the records to insert as we process the
697
732
        # stream, rather than inserting them one-by-one.  This means in the