230
232
def test_unicode_symlink(self):
231
233
# this tests bug #272444
232
self.requireFeature(tests.SymlinkFeature)
233
self.requireFeature(tests.UnicodeFilenameFeature)
234
self.requireFeature(features.SymlinkFeature)
235
self.requireFeature(features.UnicodeFilenameFeature)
235
237
tree = self.make_branch_and_tree('tree1')
240
242
target = u'\u03a9'
241
243
link_name = u'\N{Euro Sign}link'
242
244
os.symlink(target, 'tree1/' + link_name)
243
tree.add([link_name],['link-id'])
245
tree.add([link_name], ['link-id'])
245
247
revision1 = tree.commit('added a link to a Unicode target')
246
248
revision2 = tree.commit('this revision will be discarded')
388
390
def fake_up_revision(self, tree, revid, shape):
392
class ShapeTree(InventoryRevisionTree):
394
def __init__(self, shape):
395
self._repository = tree.branch.repository
396
self._inventory = shape
398
def get_file_text(self, file_id, path=None):
399
ie = self.inventory[file_id]
400
if ie.kind != "file":
402
return 'a' * ie.text_size
404
def get_file(self, file_id, path=None):
405
return StringIO(self.get_file_text(file_id))
389
407
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()
409
if shape.root.revision is None:
410
shape.root.revision = revid
411
builder = tree.branch.get_commit_builder(
415
committer="Foo Bar <foo@example.com>",
417
shape_tree = ShapeTree(shape)
418
base_tree = tree.branch.repository.revision_tree(
419
_mod_revision.NULL_REVISION)
420
changes = shape_tree.iter_changes(
422
list(builder.record_iter_changes(shape_tree,
423
base_tree.get_revision_id(), changes))
424
builder.finish_inventory()
425
builder.commit("Message")
469
480
def test_no_parents_just_root(self):
470
481
"""Test doing an empty commit - no parent, set a root only."""
471
basis_shape = Inventory(root_id=None) # empty tree
472
new_shape = Inventory() # tree with a root
482
basis_shape = Inventory(root_id=None) # empty tree
483
new_shape = Inventory() # tree with a root
473
484
self.assertTransitionFromBasisToShape(basis_shape, None, new_shape,
520
531
def do_file(inv, revid):
521
532
self.add_file(inv, revid, 'path-id', 'root-id', 'path', '1' * 32,
523
535
def do_link(inv, revid):
524
536
self.add_link(inv, revid, 'path-id', 'root-id', 'path', 'target')
525
538
def do_dir(inv, revid):
526
539
self.add_dir(inv, revid, 'path-id', 'root-id', 'path')
527
541
for old_factory in (do_file, do_link, do_dir):
528
542
for new_factory in (do_file, do_link, do_dir):
529
543
if old_factory == new_factory: