327
331
def _revision_to_objects(self, rev, tree, roundtrip):
332
"""Convert a revision to a set of git objects.
334
:param rev: Bazaar revision object
335
:param tree: Bazaar revision tree
336
:param roundtrip: Whether to roundtrip all Bazaar revision data
328
338
unusual_modes = extract_unusual_modes(rev)
329
339
present_parents = self.repository.has_revisions(rev.parent_ids)
330
340
parent_trees = self.tree_cache.revision_trees(
331
341
[p for p in rev.parent_ids if p in present_parents])
333
343
for path, obj, ie in _tree_to_objects(tree, parent_trees,
334
344
self._cache.idmap, unusual_modes):
335
345
yield path, obj, ie
348
if root_tree is None:
339
349
# Pointless commit - get the tree sha elsewhere
340
350
if not rev.parent_ids:
343
353
base_sha1 = self._lookup_revision_sha1(rev.parent_ids[0])
344
tree_sha = self[base_sha1].tree
345
commit_obj = self._reconstruct_commit(rev, tree_sha,
346
roundtrip=roundtrip) # FIXME
354
root_tree = self[base_sha1]
356
b = self.mapping.export_fileid_map({}) # FIXME
358
root_tree[self.mapping.BZR_FILE_IDS_FILE] = ((stat.S_IFREG | 0644), b.id)
359
yield self.mapping.BZR_FILE_IDS_FILE, b, None
360
commit_obj = self._reconstruct_commit(rev, root_tree.id, roundtrip=roundtrip)
348
362
foreign_revid, mapping = mapping_registry.parse_revision_id(
360
374
rev = self.repository.get_revision(revid)
361
375
tree = self.tree_cache.revision_tree(rev.revision_id)
362
376
updater = self._get_updater(rev)
363
# FIXME: roundtrip=True AND roundtrip=False
364
377
for path, obj, ie in self._revision_to_objects(rev, tree,
366
379
updater.add_object(obj, ie)
501
514
trace.mutter('entry for %s %s in shamap: %r, but not found in '
502
515
'repository', type, sha, type_data)
503
516
raise KeyError(sha)
505
517
commit = self._reconstruct_commit(rev, tree_sha, roundtrip=True)
506
518
_check_expected_sha(sha, commit)