~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/v10.py

  • Committer: Aaron Bentley
  • Date: 2007-06-20 16:08:13 UTC
  • mto: (2520.5.2 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: abentley@panoramicfeedback.com-20070620160813-2zt1l1cjypfo9ut6
Add sha1 verification for mpdiffs

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
        tail = self._base64_buffer+self._compressor.flush()
56
56
        self._fileobj.write(tail.encode('base-64'))
57
57
 
58
 
    def add_multiparent_record(self, mp_bytes, parents, repo_kind,
 
58
    def add_multiparent_record(self, mp_bytes, sha1, parents, repo_kind,
59
59
                               revision_id, file_id):
60
 
        self._add_record(mp_bytes, {'parents': parents, 
61
 
            'storage_kind': 'mpdiff'}, repo_kind, revision_id, file_id)
 
60
        metadata = {'parents': parents,
 
61
                    'storage_kind': 'mpdiff',
 
62
                    'sha1': sha1}
 
63
        self._add_record(mp_bytes, metadata, repo_kind, revision_id, file_id)
62
64
 
63
65
    def add_fulltext_record(self, bytes, parents, repo_kind, revision_id,
64
66
                            file_id):
65
 
        self._add_record(bytes, {'parents': parents, 
 
67
        self._add_record(bytes, {'parents': parents,
66
68
            'storage_kind': 'fulltext'}, repo_kind, revision_id, file_id)
67
69
 
68
70
    @staticmethod
269
271
        mpdiffs = vf.make_mpdiffs(revision_ids)
270
272
        for mpdiff, revision_id in zip(mpdiffs, revision_ids):
271
273
            parents = vf.get_parents(revision_id)
 
274
            sha1 = vf.get_sha1(revision_id)
272
275
            text = ''.join(mpdiff.to_patch())
273
 
            self.bundle.add_multiparent_record(text, parents, repo_kind,
 
276
            self.bundle.add_multiparent_record(text, sha1, parents, repo_kind,
274
277
                                               revision_id, file_id)
275
278
 
276
279
 
381
384
            raise errors.TestamentMismatch(target_revision, testament,
382
385
                                           t.as_short_text())
383
386
 
384
 
    def _install_mp_records(self, current_versionedfile, records):
 
387
    def _install_mp_records(self, versionedfile, records):
385
388
        for revision, metadata, text in records:
386
389
            mpdiff = multiparent.MultiParent.from_patch(text)
387
 
            if revision in current_versionedfile:
 
390
            if revision in versionedfile:
388
391
                continue
389
 
            current_versionedfile.add_mpdiff(revision, metadata['parents'],
 
392
            versionedfile.add_mpdiff(revision, metadata['parents'],
390
393
                                             mpdiff)
 
394
            assert metadata['sha1'] == versionedfile.get_sha1(revision)
391
395
 
392
396
    def _install_inventory(self, revision_id, metadata, text):
393
397
        vf = self._repository.get_inventory_weave()