~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_conflicts.py

  • Committer: Jelmer Vernooij
  • Date: 2011-02-21 15:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 5675.
  • Revision ID: jelmer@samba.org-20110221150919-v7nnbontcuhi1dmu
Move Repository._find_text_key_references_from_xml_inventory_lines onto the serializer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
class TestConflicts(tests.TestCaseWithTransport):
66
66
 
 
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'),
 
77
                                  ])
 
78
        tree.lock_read()
 
79
        self.assertLength(6, list(tree.list_files()))
 
80
        tree.unlock()
 
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')
 
93
 
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')]
447
474
 
448
475
    def check_file_doesnt_exist(self):
449
 
        self.assertPathDoesNotExist('branch/file')
 
476
        self.failIfExists('branch/file')
450
477
 
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')
460
487
 
461
488
    def check_file_in_dir_doesnt_exist(self):
462
 
        self.assertPathDoesNotExist('branch/dir/file')
 
489
        self.failIfExists('branch/dir/file')
463
490
 
464
491
    def _get_resolve_path_arg(self, wt, action):
465
492
        return self._path
540
567
        return [('rename', ('file', 'new-file'))]
541
568
 
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')
545
572
 
546
573
    def do_rename_file2(self):
547
574
        return [('rename', ('file', 'new-file2'))]
548
575
 
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')
552
579
 
553
580
    def do_rename_dir(self):
554
581
        return [('rename', ('dir', 'new-dir'))]
555
582
 
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')
559
586
 
560
587
    def do_rename_dir2(self):
561
588
        return [('rename', ('dir', 'new-dir2'))]
562
589
 
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')
566
593
 
567
594
    def do_delete_file(self):
568
595
        return [('unversion', 'file-id')]
569
596
 
570
597
    def check_file_doesnt_exist(self):
571
 
        self.assertPathDoesNotExist('branch/file')
 
598
        self.failIfExists('branch/file')
572
599
 
573
600
    def do_delete_dir(self):
574
601
        return [('unversion', 'dir-id')]
575
602
 
576
603
    def check_dir_doesnt_exist(self):
577
 
        self.assertPathDoesNotExist('branch/dir')
 
604
        self.failIfExists('branch/dir')
578
605
 
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'))]
585
612
 
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')
589
616
 
590
617
    def check_file_in_dir_doesnt_exist(self):
591
 
        self.assertPathDoesNotExist('branch/dir/file')
 
618
        self.failIfExists('branch/dir/file')
592
619
 
593
620
    def _get_resolve_path_arg(self, wt, action):
594
621
        tpath = self._this['path']
885
912
        return [('rename', ('dir1', 'dir2/dir1'))]
886
913
 
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')
890
917
 
891
918
    def do_move_dir2_into_dir1(self):
892
919
        return [('rename', ('dir2', 'dir1/dir2'))]
893
920
 
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')
897
924
 
898
925
    def do_create_dir1_4(self):
899
926
        return [('add', ('dir1', 'dir1-id', 'directory', '')),
905
932
        return [('rename', ('dir1', 'dir3/dir4/dir1'))]
906
933
 
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')
911
938
 
912
939
    def do_move_dir3_into_dir2(self):
913
940
        return [('rename', ('dir3', 'dir1/dir2/dir3'))]
914
941
 
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')
919
946
 
920
947
    def _get_resolve_path_arg(self, wt, action):
921
948
        # ParentLoop says: moving <conflict_path> into <path>. Cancelled move.