386
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))
387
404
tree.lock_write()
389
tree.branch.repository.start_write_group()
391
if shape.root.revision is None:
392
shape.root.revision = revid
393
# Create the text records for this inventory.
394
for path, ie in shape.iter_entries():
396
lines = ['a' * ie.text_size]
399
tree.branch.repository.texts.add_lines(
400
(ie.file_id, ie.revision), [], lines)
401
sha1 = tree.branch.repository.add_inventory(revid, shape, [])
402
rev = Revision(timestamp=0,
404
committer="Foo Bar <foo@example.com>",
408
tree.branch.repository.add_revision(revid, rev)
409
tree.branch.repository.commit_write_group()
411
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")