388
387
def fake_up_revision(self, tree, revid, shape):
389
class ShapeTree(InventoryRevisionTree):
391
def __init__(self, shape):
392
self._repository = tree.branch.repository
393
self._inventory = shape
395
def get_file_text(self, file_id, path=None):
396
ie = self.inventory[file_id]
397
if ie.kind != "file":
399
return 'a' * ie.text_size
401
def get_file(self, file_id, path=None):
402
return StringIO(self.get_file_text(file_id))
389
404
tree.lock_write()
391
tree.branch.repository.start_write_group()
393
if shape.root.revision is None:
394
shape.root.revision = revid
395
# Create the text records for this inventory.
396
for path, ie in shape.iter_entries():
398
lines = ['a' * ie.text_size]
401
tree.branch.repository.texts.add_lines(
402
(ie.file_id, ie.revision), [], lines)
403
sha1 = tree.branch.repository.add_inventory(revid, shape, [])
404
rev = Revision(timestamp=0,
406
committer="Foo Bar <foo@example.com>",
410
tree.branch.repository.add_revision(revid, rev)
411
tree.branch.repository.commit_write_group()
413
tree.branch.repository.abort_write_group()
406
if shape.root.revision is None:
407
shape.root.revision = revid
408
builder = tree.branch.get_commit_builder(
412
committer="Foo Bar <foo@example.com>",
414
shape_tree = ShapeTree(shape)
415
base_tree = tree.branch.repository.revision_tree(
416
_mod_revision.NULL_REVISION)
417
changes = shape_tree.iter_changes(
419
list(builder.record_iter_changes(shape_tree,
420
base_tree.get_revision_id(), changes))
421
builder.finish_inventory()
422
builder.commit("Message")