338
356
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('e', 'e-id'),
339
357
('a/b', 'b-id'), ('a/c', 'c-id'),
340
358
('a/c/d', 'd-id')], tree.basis_tree())
361
def test_move_directory_into_parent(self):
362
tree = self.make_branch_and_tree('.')
363
self.build_tree(['c/', 'c/b/', 'c/b/d/'])
364
tree.add(['c', 'c/b', 'c/b/d'],
365
['c-id', 'b-id', 'd-id'])
366
tree.commit('initial', rev_id='rev-1')
367
root_id = tree.get_root_id()
369
self.assertEqual([('c/b', 'b')],
370
tree.move(['c/b'], ''))
371
self.assertTreeLayout([('', root_id),
378
def test_move_directory_with_children_in_subdir(self):
379
tree = self.make_branch_and_tree('.')
380
self.build_tree(['a/', 'a/b', 'a/c/', 'd/'])
381
tree.add(['a', 'a/b', 'a/c', 'd'],
382
['a-id', 'b-id', 'c-id', 'd-id'])
383
tree.commit('initial', rev_id='rev-1')
384
root_id = tree.get_root_id()
387
tree.rename_one('a/b', 'a/c/b')
388
self.assertTreeLayout([('', root_id),
394
self.assertEqual([('a', 'd/a')],
395
tree.move(['a'], 'd'))
396
self.assertTreeLayout([('', root_id),
404
def test_move_directory_with_deleted_children(self):
405
tree = self.make_branch_and_tree('.')
406
self.build_tree(['a/', 'a/b', 'a/c', 'a/d', 'b/'])
407
tree.add(['a', 'b', 'a/b', 'a/c', 'a/d'],
408
['a-id', 'b-id', 'ab-id', 'ac-id', 'ad-id'])
409
tree.commit('initial', rev_id='rev-1')
410
root_id = tree.get_root_id()
412
tree.remove(['a/b', 'a/d'])
414
self.assertEqual([('a', 'b/a')],
415
tree.move(['a'], 'b'))
416
self.assertTreeLayout([('', root_id),
423
def test_move_directory_with_new_children(self):
424
tree = self.make_branch_and_tree('.')
425
self.build_tree(['a/', 'a/c', 'b/'])
426
tree.add(['a', 'b', 'a/c'], ['a-id', 'b-id', 'ac-id'])
427
tree.commit('initial', rev_id='rev-1')
428
root_id = tree.get_root_id()
430
self.build_tree(['a/b', 'a/d'])
431
tree.add(['a/b', 'a/d'], ['ab-id', 'ad-id'])
433
self.assertEqual([('a', 'b/a')],
434
tree.move(['a'], 'b'))
435
self.assertTreeLayout([('', root_id),
444
def test_move_directory_with_moved_children(self):
445
tree = self.make_branch_and_tree('.')
446
self.build_tree(['a/', 'a/b', 'a/c', 'd', 'e/'])
447
tree.add(['a', 'a/b', 'a/c', 'd', 'e'],
448
['a-id', 'b-id', 'c-id', 'd-id', 'e-id'])
449
tree.commit('initial', rev_id='rev-1')
450
root_id = tree.get_root_id()
452
self.assertEqual([('a/b', 'b')],
453
tree.move(['a/b'], ''))
454
self.assertTreeLayout([('', root_id),
461
self.assertEqual([('d', 'a/d')],
462
tree.move(['d'], 'a'))
463
self.assertTreeLayout([('', root_id),
470
self.assertEqual([('a', 'e/a')],
471
tree.move(['a'], 'e'))
472
self.assertTreeLayout([('', root_id),
481
def test_move_directory_with_renamed_child(self):
482
tree = self.make_branch_and_tree('.')
483
self.build_tree(['a/', 'a/b', 'a/c', 'd/'])
484
tree.add(['a', 'a/b', 'a/c', 'd'],
485
['a-id', 'b-id', 'c-id', 'd-id'])
486
tree.commit('initial', rev_id='rev-1')
487
root_id = tree.get_root_id()
489
tree.rename_one('a/b', 'a/d')
490
self.assertTreeLayout([('', root_id),
496
self.assertEqual([('a', 'd/a')],
497
tree.move(['a'], 'd'))
498
self.assertTreeLayout([('', root_id),
506
def test_move_directory_with_swapped_children(self):
507
tree = self.make_branch_and_tree('.')
508
self.build_tree(['a/', 'a/b', 'a/c', 'a/d', 'e/'])
509
tree.add(['a', 'a/b', 'a/c', 'a/d', 'e'],
510
['a-id', 'b-id', 'c-id', 'd-id', 'e-id'])
511
tree.commit('initial', rev_id='rev-1')
512
root_id = tree.get_root_id()
514
tree.rename_one('a/b', 'a/bb')
515
tree.rename_one('a/d', 'a/b')
516
tree.rename_one('a/bb', 'a/d')
517
self.assertTreeLayout([('', root_id),
524
self.assertEqual([('a', 'e/a')],
525
tree.move(['a'], 'e'))
526
self.assertTreeLayout([('', root_id),
342
535
def test_move_moved(self):
343
536
"""Moving a moved entry works as expected."""