/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

Cope with tuples in refs dictionary.

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
    )
35
36
from bzrlib.revision import (
36
37
    NULL_REVISION,
37
38
    )
 
39
from bzrlib.testament import(
 
40
    StrictTestament3,
 
41
    )
38
42
 
39
43
from bzrlib.plugins.git.mapping import (
40
44
    default_mapping,
220
224
            new_trees[posixpath.dirname(path[1])] = parent[1]
221
225
        elif kind[1] not in (None, "directory"):
222
226
            raise AssertionError(kind[1])
223
 
        if path[0] is not None and parent[0] in tree.inventory and tree.inventory[parent[0]].kind == "directory":
 
227
        if (path[0] not in (None, "") and
 
228
            parent[0] in tree.inventory and
 
229
            tree.inventory[parent[0]].kind == "directory"):
224
230
            # Removal
225
231
            new_trees[posixpath.dirname(path[0])] = parent[0]
226
232
    
336
342
        self._update_sha_map()
337
343
        return iter(self._cache.idmap.sha1s())
338
344
 
339
 
    def _reconstruct_commit(self, rev, tree_sha, roundtrip):
 
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
        """
340
354
        def parent_lookup(revid):
341
355
            try:
342
356
                return self._lookup_revision_sha1(revid)
343
357
            except errors.NoSuchRevision:
344
358
                return None
345
359
        return self.mapping.export_commit(rev, tree_sha, parent_lookup,
346
 
            roundtrip)
 
360
            roundtrip, verifiers)
347
361
 
348
362
    def _create_fileid_map_blob(self, inv):
349
363
        # FIXME: This can probably be a lot more efficient, 
388
402
                root_tree[self.mapping.BZR_FILE_IDS_FILE] = ((stat.S_IFREG | 0644), b.id)
389
403
                yield self.mapping.BZR_FILE_IDS_FILE, b, None
390
404
        yield "", root_tree, root_ie
 
405
        if roundtrip:
 
406
            testament3 = StrictTestament3(rev, tree.inventory)
 
407
            verifiers = { "testament3-sha1": testament3.as_sha1() }
 
408
        else:
 
409
            verifiers = {}
391
410
        commit_obj = self._reconstruct_commit(rev, root_tree.id,
392
 
            roundtrip=roundtrip)
 
411
            roundtrip=roundtrip, verifiers=verifiers)
393
412
        try:
394
413
            foreign_revid, mapping = mapping_registry.parse_revision_id(
395
414
                rev.revision_id)
408
427
        updater = self._get_updater(rev)
409
428
        for path, obj, ie in self._revision_to_objects(rev, tree,
410
429
            roundtrip=True):
 
430
            if isinstance(obj, Commit):
 
431
                testament3 = StrictTestament3(rev, tree.inventory)
 
432
                ie = { "testament3-sha1": testament3.as_sha1() }
411
433
            updater.add_object(obj, ie, path)
412
434
        commit_obj = updater.finish()
413
435
        return commit_obj.id
553
575
        (type, type_data) = self.lookup_git_sha(sha)
554
576
        # convert object to git object
555
577
        if type == "commit":
556
 
            (revid, tree_sha) = type_data
 
578
            (revid, tree_sha, verifiers) = type_data
557
579
            try:
558
580
                rev = self.repository.get_revision(revid)
559
581
            except errors.NoSuchRevision:
560
582
                trace.mutter('entry for %s %s in shamap: %r, but not found in '
561
583
                             'repository', type, sha, type_data)
562
584
                raise KeyError(sha)
563
 
            commit = self._reconstruct_commit(rev, tree_sha, roundtrip=True)
 
585
            commit = self._reconstruct_commit(rev, tree_sha, roundtrip=True,
 
586
                verifiers=verifiers)
564
587
            _check_expected_sha(sha, commit)
565
588
            return commit
566
589
        elif type == "blob":