274
277
def import_git_commit(repo, mapping, head, lookup_object,
275
target_git_object_retriever, parent_invs_cache):
278
target_git_object_retriever, trees_cache):
276
279
o = lookup_object(head)
277
280
rev = mapping.import_commit(o)
278
281
# We have to do this here, since we have to walk the tree and
279
282
# we need to make sure to import the blobs / trees with the right
280
283
# path; this may involve adding them more than once.
281
parent_invs = parent_invs_cache.get_inventories(rev.parent_ids)
282
if parent_invs == []:
284
parent_trees = trees_cache.revision_trees(rev.parent_ids)
285
if parent_trees == []:
283
286
base_inv = Inventory(root_id=None)
287
base_inv = parent_invs[0]
290
base_inv = parent_trees[0].inventory
288
291
base_tree = lookup_object(o.parents[0]).tree
289
292
base_mode = stat.S_IFDIR
290
293
store_updater = target_git_object_retriever._get_updater(rev)
291
294
store_updater.add_object(o, None)
292
295
inv_delta, unusual_modes = import_git_tree(repo.texts,
293
296
mapping, "", u"", (base_tree, o.tree), base_inv,
294
None, rev.revision_id, parent_invs, lookup_object,
295
(base_mode, stat.S_IFDIR), store_updater,
297
None, rev.revision_id, [p.inventory for p in parent_trees],
298
lookup_object, (base_mode, stat.S_IFDIR), store_updater,
296
299
allow_submodules=getattr(repo._format, "supports_tree_reference", False))
297
300
store_updater.finish()
298
301
if unusual_modes != {}:
307
310
rev.inventory_sha1, inv = repo.add_inventory_by_delta(basis_id,
308
311
inv_delta, rev.revision_id, rev.parent_ids,
310
parent_invs_cache.add(rev.revision_id, inv)
313
trees_cache.add(RevisionTree(repo, inv, rev.revision_id))
311
314
repo.add_revision(rev.revision_id, rev)
312
315
if "verify" in debug.debug_flags:
313
316
new_unusual_modes = mapping.export_unusual_file_modes(rev)