/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to object_store.py

Use dictionary with verifiers rather than requiring testament3-sha1 everywhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from dulwich.objects import (
20
20
    Blob,
 
21
    Commit,
21
22
    Tree,
22
23
    sha_to_hex,
23
24
    )
341
342
        self._update_sha_map()
342
343
        return iter(self._cache.idmap.sha1s())
343
344
 
344
 
    def _reconstruct_commit(self, rev, tree_sha, roundtrip, testament3_sha1):
 
345
    def _reconstruct_commit(self, rev, tree_sha, roundtrip, verifiers):
 
346
        """Reconstruct a Commit object.
 
347
 
 
348
        :param rev: Revision object
 
349
        :param tree_sha: SHA1 of the root tree object
 
350
        :param roundtrip: Whether or not to roundtrip bzr metadata
 
351
        :param verifiers: Verifiers for the commits
 
352
        :return: Commit object
 
353
        """
345
354
        def parent_lookup(revid):
346
355
            try:
347
356
                return self._lookup_revision_sha1(revid)
348
357
            except errors.NoSuchRevision:
349
358
                return None
350
359
        return self.mapping.export_commit(rev, tree_sha, parent_lookup,
351
 
            roundtrip, testament3_sha1)
 
360
            roundtrip, verifiers)
352
361
 
353
362
    def _create_fileid_map_blob(self, inv):
354
363
        # FIXME: This can probably be a lot more efficient, 
395
404
        yield "", root_tree, root_ie
396
405
        if roundtrip:
397
406
            testament3 = StrictTestament3(rev, tree.inventory)
398
 
            testament3_sha1 = testament3.as_sha1()
 
407
            verifiers = { "testament3-sha1": testament3.as_sha1() }
399
408
        else:
400
 
            testament3_sha1 = None
 
409
            verifiers = {}
401
410
        commit_obj = self._reconstruct_commit(rev, root_tree.id,
402
 
            roundtrip=roundtrip, testament3_sha1=testament3_sha1)
 
411
            roundtrip=roundtrip, verifiers=verifiers)
403
412
        try:
404
413
            foreign_revid, mapping = mapping_registry.parse_revision_id(
405
414
                rev.revision_id)
418
427
        updater = self._get_updater(rev)
419
428
        for path, obj, ie in self._revision_to_objects(rev, tree,
420
429
            roundtrip=True):
 
430
            if isinstance(obj, Commit):
 
431
                testament3 = StrictTestament3(rev, tree.inventory)
 
432
                ie = { "testament3-sha1": testament3.as_sha1() }
421
433
            updater.add_object(obj, ie, path)
422
434
        commit_obj = updater.finish()
423
435
        return commit_obj.id
563
575
        (type, type_data) = self.lookup_git_sha(sha)
564
576
        # convert object to git object
565
577
        if type == "commit":
566
 
            (revid, tree_sha) = type_data
 
578
            (revid, tree_sha, verifiers) = type_data
567
579
            try:
568
580
                rev = self.repository.get_revision(revid)
569
581
            except errors.NoSuchRevision:
570
582
                trace.mutter('entry for %s %s in shamap: %r, but not found in '
571
583
                             'repository', type, sha, type_data)
572
584
                raise KeyError(sha)
573
 
            commit = self._reconstruct_commit(rev, tree_sha, roundtrip=True)
 
585
            commit = self._reconstruct_commit(rev, tree_sha, roundtrip=True,
 
586
                verifiers=verifiers)
574
587
            _check_expected_sha(sha, commit)
575
588
            return commit
576
589
        elif type == "blob":