65
65
class TestConflicts(tests.TestCaseWithTransport):
67
def test_conflicts(self):
68
"""Conflicts are detected properly"""
69
# Use BzrDirFormat6 so we can fake conflicts
70
tree = self.make_branch_and_tree('.', format=bzrdir.BzrDirFormat6())
71
self.build_tree_contents([('hello', 'hello world4'),
72
('hello.THIS', 'hello world2'),
73
('hello.BASE', 'hello world1'),
74
('hello.OTHER', 'hello world3'),
75
('hello.sploo.BASE', 'yellowworld'),
76
('hello.sploo.OTHER', 'yellowworld2'),
79
self.assertLength(6, list(tree.list_files()))
81
tree_conflicts = tree.conflicts()
82
self.assertLength(2, tree_conflicts)
83
self.assertTrue('hello' in tree_conflicts[0].path)
84
self.assertTrue('hello.sploo' in tree_conflicts[1].path)
85
conflicts.restore('hello')
86
conflicts.restore('hello.sploo')
87
self.assertLength(0, tree.conflicts())
88
self.assertFileEqual('hello world2', 'hello')
89
self.assertFalse(os.path.lexists('hello.sploo'))
90
self.assertRaises(errors.NotConflicted, conflicts.restore, 'hello')
91
self.assertRaises(errors.NotConflicted,
92
conflicts.restore, 'hello.sploo')
67
94
def test_resolve_conflict_dir(self):
68
95
tree = self.make_branch_and_tree('.')
69
96
self.build_tree_contents([('hello', 'hello world4'),
446
473
return [('unversion', 'file-id')]
448
475
def check_file_doesnt_exist(self):
449
self.assertPathDoesNotExist('branch/file')
476
self.failIfExists('branch/file')
451
478
def do_create_file_in_dir(self):
452
479
return [('add', ('dir', 'dir-id', 'directory', '')),
459
486
self.assertFileEqual('trunk content\nmore content\n', 'branch/dir/file')
461
488
def check_file_in_dir_doesnt_exist(self):
462
self.assertPathDoesNotExist('branch/dir/file')
489
self.failIfExists('branch/dir/file')
464
491
def _get_resolve_path_arg(self, wt, action):
465
492
return self._path
540
567
return [('rename', ('file', 'new-file'))]
542
569
def check_file_renamed(self):
543
self.assertPathDoesNotExist('branch/file')
544
self.assertPathExists('branch/new-file')
570
self.failIfExists('branch/file')
571
self.failUnlessExists('branch/new-file')
546
573
def do_rename_file2(self):
547
574
return [('rename', ('file', 'new-file2'))]
549
576
def check_file_renamed2(self):
550
self.assertPathDoesNotExist('branch/file')
551
self.assertPathExists('branch/new-file2')
577
self.failIfExists('branch/file')
578
self.failUnlessExists('branch/new-file2')
553
580
def do_rename_dir(self):
554
581
return [('rename', ('dir', 'new-dir'))]
556
583
def check_dir_renamed(self):
557
self.assertPathDoesNotExist('branch/dir')
558
self.assertPathExists('branch/new-dir')
584
self.failIfExists('branch/dir')
585
self.failUnlessExists('branch/new-dir')
560
587
def do_rename_dir2(self):
561
588
return [('rename', ('dir', 'new-dir2'))]
563
590
def check_dir_renamed2(self):
564
self.assertPathDoesNotExist('branch/dir')
565
self.assertPathExists('branch/new-dir2')
591
self.failIfExists('branch/dir')
592
self.failUnlessExists('branch/new-dir2')
567
594
def do_delete_file(self):
568
595
return [('unversion', 'file-id')]
570
597
def check_file_doesnt_exist(self):
571
self.assertPathDoesNotExist('branch/file')
598
self.failIfExists('branch/file')
573
600
def do_delete_dir(self):
574
601
return [('unversion', 'dir-id')]
576
603
def check_dir_doesnt_exist(self):
577
self.assertPathDoesNotExist('branch/dir')
604
self.failIfExists('branch/dir')
579
606
def do_create_file_in_dir(self):
580
607
return [('add', ('dir', 'dir-id', 'directory', '')),
584
611
return [('rename', ('dir/file', 'dir/new-file'))]
586
613
def check_file_in_dir_renamed(self):
587
self.assertPathDoesNotExist('branch/dir/file')
588
self.assertPathExists('branch/dir/new-file')
614
self.failIfExists('branch/dir/file')
615
self.failUnlessExists('branch/dir/new-file')
590
617
def check_file_in_dir_doesnt_exist(self):
591
self.assertPathDoesNotExist('branch/dir/file')
618
self.failIfExists('branch/dir/file')
593
620
def _get_resolve_path_arg(self, wt, action):
594
621
tpath = self._this['path']
885
912
return [('rename', ('dir1', 'dir2/dir1'))]
887
914
def check_dir1_moved(self):
888
self.assertPathDoesNotExist('branch/dir1')
889
self.assertPathExists('branch/dir2/dir1')
915
self.failIfExists('branch/dir1')
916
self.failUnlessExists('branch/dir2/dir1')
891
918
def do_move_dir2_into_dir1(self):
892
919
return [('rename', ('dir2', 'dir1/dir2'))]
894
921
def check_dir2_moved(self):
895
self.assertPathDoesNotExist('branch/dir2')
896
self.assertPathExists('branch/dir1/dir2')
922
self.failIfExists('branch/dir2')
923
self.failUnlessExists('branch/dir1/dir2')
898
925
def do_create_dir1_4(self):
899
926
return [('add', ('dir1', 'dir1-id', 'directory', '')),
905
932
return [('rename', ('dir1', 'dir3/dir4/dir1'))]
907
934
def check_dir1_2_moved(self):
908
self.assertPathDoesNotExist('branch/dir1')
909
self.assertPathExists('branch/dir3/dir4/dir1')
910
self.assertPathExists('branch/dir3/dir4/dir1/dir2')
935
self.failIfExists('branch/dir1')
936
self.failUnlessExists('branch/dir3/dir4/dir1')
937
self.failUnlessExists('branch/dir3/dir4/dir1/dir2')
912
939
def do_move_dir3_into_dir2(self):
913
940
return [('rename', ('dir3', 'dir1/dir2/dir3'))]
915
942
def check_dir3_4_moved(self):
916
self.assertPathDoesNotExist('branch/dir3')
917
self.assertPathExists('branch/dir1/dir2/dir3')
918
self.assertPathExists('branch/dir1/dir2/dir3/dir4')
943
self.failIfExists('branch/dir3')
944
self.failUnlessExists('branch/dir1/dir2/dir3')
945
self.failUnlessExists('branch/dir1/dir2/dir3/dir4')
920
947
def _get_resolve_path_arg(self, wt, action):
921
948
# ParentLoop says: moving <conflict_path> into <path>. Cancelled move.