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

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
from ..bzr.testament import (
56
56
    StrictTestament3,
57
57
    )
58
 
from ..tree import InterTree
59
58
from ..tsort import (
60
59
    topo_sort,
61
60
    )
126
125
    # Check what revision we should store
127
126
    parent_keys = []
128
127
    for ptree in parent_bzr_trees:
129
 
        intertree = InterTree.get(ptree, base_bzr_tree)
130
128
        try:
131
 
            ppath = intertree.find_source_paths(decoded_path, recurse='none')
132
 
        except errors.NoSuchFile:
133
 
            continue
134
 
        if ppath is None:
 
129
            ppath = ptree.id2path(file_id)
 
130
        except errors.NoSuchId:
135
131
            continue
136
132
        pkind = ptree.kind(ppath)
137
133
        if (pkind == ie.kind and
186
182
    (base_mode, mode) = modes
187
183
    if base_hexsha == hexsha and base_mode == mode:
188
184
        return [], {}
189
 
    path = path.decode('utf-8')
190
185
    file_id = lookup_file_id(path)
191
186
    invdelta = []
192
187
    ie = TreeReference(file_id, name.decode("utf-8"), parent_id)
193
188
    ie.revision = revision_id
194
189
    if base_hexsha is not None:
195
 
        old_path = path  # Renames are not supported yet
 
190
        old_path = path.decode("utf-8")  # Renames are not supported yet
196
191
        if stat.S_ISDIR(base_mode):
197
192
            invdelta.extend(remove_disappeared_children(
198
193
                base_bzr_tree, old_path, lookup_object(base_hexsha), [],
383
378
 
384
379
 
385
380
def import_git_commit(repo, mapping, head, lookup_object,
386
 
                      target_git_object_retriever, trees_cache, strict):
 
381
                      target_git_object_retriever, trees_cache):
387
382
    o = lookup_object(head)
388
383
    # Note that this uses mapping.revision_id_foreign_to_bzr. If the parents
389
384
    # were bzr roundtripped revisions they would be specified in the
390
385
    # roundtrip data.
391
386
    rev, roundtrip_revid, verifiers = mapping.import_commit(
392
 
        o, mapping.revision_id_foreign_to_bzr, strict)
 
387
        o, mapping.revision_id_foreign_to_bzr)
393
388
    if roundtrip_revid is not None:
394
389
        original_revid = rev.revision_id
395
390
        rev.revision_id = roundtrip_revid
407
402
        base_tree = lookup_object(o.parents[0]).tree
408
403
        base_mode = stat.S_IFDIR
409
404
    store_updater = target_git_object_retriever._get_updater(rev)
 
405
    tree_supplement = mapping.get_fileid_map(lookup_object, o.tree)
410
406
    inv_delta, unusual_modes = import_git_tree(
411
407
        repo.texts, mapping, b"", b"", (base_tree, o.tree), base_bzr_tree,
412
408
        None, rev.revision_id, parent_trees, lookup_object,
413
409
        (base_mode, stat.S_IFDIR), store_updater,
414
 
        mapping.generate_file_id,
 
410
        tree_supplement.lookup_file_id,
415
411
        allow_submodules=repo._format.supports_tree_reference)
416
412
    if unusual_modes != {}:
417
413
        for path, mode in unusual_modes.iteritems():
487
483
            continue
488
484
        if isinstance(o, Commit):
489
485
            rev, roundtrip_revid, verifiers = mapping.import_commit(
490
 
                o, mapping.revision_id_foreign_to_bzr, strict=True)
 
486
                o, mapping.revision_id_foreign_to_bzr)
491
487
            if (repo.has_revision(rev.revision_id)
492
488
                    or (roundtrip_revid and
493
489
                        repo.has_revision(roundtrip_revid))):
520
516
                        pb.update("fetching revisions", offset + i,
521
517
                                  len(revision_ids))
522
518
                    import_git_commit(repo, mapping, head, lookup_object,
523
 
                                      target_git_object_retriever, trees_cache,
524
 
                                      strict=True)
 
519
                                      target_git_object_retriever, trees_cache)
525
520
                    last_imported = head
526
521
            except BaseException:
527
522
                repo.abort_write_group()