/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 fetch.py

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
344
344
def import_git_commit(repo, mapping, head, lookup_object,
345
345
                      target_git_object_retriever, trees_cache):
346
346
    o = lookup_object(head)
347
 
    rev, roundtrip_revid, testament3_sha1 = mapping.import_commit(o,
 
347
    rev, roundtrip_revid, verifiers = mapping.import_commit(o,
348
348
            lambda x: target_git_object_retriever.lookup_git_sha(x)[1][0])
349
349
    # We have to do this here, since we have to walk the tree and
350
350
    # we need to make sure to import the blobs / trees with the right
359
359
        base_tree = lookup_object(o.parents[0]).tree
360
360
        base_mode = stat.S_IFDIR
361
361
    store_updater = target_git_object_retriever._get_updater(rev)
362
 
    store_updater.add_object(o, None, None)
363
362
    fileid_map = mapping.get_fileid_map(lookup_object, o.tree)
364
363
    inv_delta, unusual_modes = import_git_tree(repo.texts,
365
364
            mapping, "", "", (base_tree, o.tree), base_inv,
367
366
            lookup_object, (base_mode, stat.S_IFDIR), store_updater,
368
367
            fileid_map.lookup_file_id,
369
368
            allow_submodules=getattr(repo._format, "supports_tree_reference", False))
370
 
    store_updater.finish()
371
369
    if unusual_modes != {}:
372
370
        for path, mode in unusual_modes.iteritems():
373
371
            warn_unusual_mode(rev.foreign_revid, path, mode)
379
377
        base_inv = None
380
378
    rev.inventory_sha1, inv = repo.add_inventory_by_delta(basis_id,
381
379
              inv_delta, rev.revision_id, rev.parent_ids, base_inv)
382
 
    # FIXME: Check testament3_sha1
 
380
    # FIXME: Check verifiers
 
381
    testament = StrictTestament3(rev, inv)
 
382
    calculated_verifiers = { "testament3-sha1": testament.as_sha1() }
383
383
    if roundtrip_revid is not None:
384
384
        original_revid = rev.revision_id
385
385
        rev.revision_id = roundtrip_revid
386
 
        testament = StrictTestament3(rev, inv)
387
 
        if testament.as_sha1() != testament3_sha1:
 
386
        if calculated_verifiers != verifiers:
388
387
            trace.mutter("Testament SHA1 %r for %r did not match %r.",
389
 
                         testament.as_sha1(), rev.revision_id, 
390
 
                         testament3_sha1)
 
388
                         calculated_verifiers["testament3-sha1"],
 
389
                         rev.revision_id, verifiers["testament3-sha1"])
391
390
            rev.revision_id = original_revid
 
391
    store_updater.add_object(o, calculated_verifiers, None)
 
392
    store_updater.finish()
392
393
    ret_tree = RevisionTree(repo, inv, rev.revision_id)
393
394
    trees_cache.add(ret_tree)
394
395
    repo.add_revision(rev.revision_id, rev)
427
428
        except KeyError:
428
429
            continue
429
430
        if isinstance(o, Commit):
430
 
            rev, roundtrip_revid, testament3_sha1 = mapping.import_commit(o,
 
431
            rev, roundtrip_revid, verifiers = mapping.import_commit(o,
431
432
                lambda x: None)
432
433
            if (repo.has_revision(rev.revision_id) or
433
434
                (roundtrip_revid and repo.has_revision(roundtrip_revid))):