147
147
except AttributeError: # older version of dulwich
148
148
chunks = [blob.data]
149
149
texts.insert_record_stream([ChunkedContentFactory((file_id, ie.revision), tuple(parent_keys), ie.text_sha1, chunks)])
150
shamap = { ie.file_id: hexsha }
152
151
if base_hexsha is not None:
153
152
old_path = path # Renames are not supported yet
159
158
invdelta.append((old_path, path, file_id, ie))
160
return (invdelta, shamap)
159
return (invdelta, [(ie.file_id, "blob", hexsha, ie.revision)])
163
162
class SubmodulesRequireSubtrees(BzrError):
180
179
ie.reference_revision = mapping.revision_id_foreign_to_bzr(hexsha)
181
180
texts.insert_record_stream([ChunkedContentFactory((file_id, ie.revision), (), None, [])])
182
181
invdelta = [(oldpath, path, file_id, ie)]
183
return invdelta, {}, {}
182
return invdelta, {}, []
186
185
def remove_disappeared_children(base_inv, path, base_tree, existing_children,
229
228
# Remember for next time
230
229
existing_children = set()
231
shamap = [(ie.file_id, "tree", hexsha, revision_id)]
233
232
for child_mode, name, child_hexsha in tree.entries():
234
233
existing_children.add(name)
235
234
child_path = posixpath.join(path, name)
268
267
grandchildmodes = {}
269
268
child_modes.update(grandchildmodes)
270
269
invdelta.extend(subinvdelta)
271
shamap.update(subshamap)
270
shamap.extend(subshamap)
272
271
if child_mode not in (stat.S_IFDIR, DEFAULT_FILE_MODE,
273
272
stat.S_IFLNK, DEFAULT_FILE_MODE|0111):
274
273
child_modes[child_path] = child_mode
276
275
if base_tree is not None and type(base_tree) is Tree:
277
276
invdelta.extend(remove_disappeared_children(base_inv, old_path,
278
277
base_tree, existing_children, lookup_object))
279
shamap[file_id] = hexsha
280
278
return invdelta, child_modes, shamap
298
296
base_inv_shamap = target_git_object_retriever._idmap.get_inventory_sha_map(base_inv.revision_id)
299
297
base_tree = lookup_object(o.parents[0]).tree
300
298
base_mode = stat.S_IFDIR
301
inv_delta, unusual_modes, shamap = import_git_tree(repo.texts,
299
inv_delta, unusual_modes, entries = import_git_tree(repo.texts,
302
300
mapping, "", u"", (base_tree, o.tree), base_inv, base_inv_shamap,
303
301
None, rev.revision_id, parent_invs, lookup_object,
304
302
(base_mode, stat.S_IFDIR),
305
303
allow_submodules=getattr(repo._format, "supports_tree_reference", False))
307
for (oldpath, newpath, fileid, new_ie) in inv_delta:
309
entries.append((fileid, None, None, None))
311
if new_ie.kind in ("file", "symlink"):
312
entries.append((fileid, "blob", shamap[fileid], new_ie.revision))
313
elif new_ie.kind == "directory":
314
entries.append((fileid, "tree", shamap[fileid], rev.revision_id))
317
304
target_git_object_retriever._idmap.add_entries(rev.revision_id,
318
305
rev.parent_ids, head, o.tree, entries)
319
306
if unusual_modes != {}: