~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_conflicts.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-30 18:28:17 UTC
  • mfrom: (5967.10.2 test-cat)
  • Revision ID: pqm@pqm.ubuntu.com-20110630182817-83a5q9r9rxfkdn8r
(mbp) don't use subprocesses for testing cat (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import os
19
19
 
20
20
from bzrlib import (
 
21
    bzrdir,
21
22
    conflicts,
22
23
    errors,
23
24
    option,
676
677
             ('fileb_created',
677
678
              dict(actions='create_file_b', check='file_content_b',
678
679
                   path='file', file_id='file-b-id')),),
679
 
            # File created with different file-ids but deleted on one side
680
 
            (dict(_base_actions='create_file_a'),
681
 
             ('filea_replaced',
682
 
              dict(actions='replace_file_a_by_b', check='file_content_b',
683
 
                   path='file', file_id='file-b-id')),
684
 
             ('filea_modified',
685
 
              dict(actions='modify_file_a', check='file_new_content',
686
 
                   path='file', file_id='file-a-id')),),
687
680
            ])
688
681
 
689
682
    def do_nothing(self):
701
694
    def check_file_content_b(self):
702
695
        self.assertFileEqual('file b content\n', 'branch/file')
703
696
 
704
 
    def do_replace_file_a_by_b(self):
705
 
        return [('unversion', 'file-a-id'),
706
 
                ('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
707
 
 
708
 
    def do_modify_file_a(self):
709
 
        return [('modify', ('file-a-id', 'new content\n'))]
710
 
 
711
 
    def check_file_new_content(self):
712
 
        self.assertFileEqual('new content\n', 'branch/file')
713
 
 
714
697
    def _get_resolve_path_arg(self, wt, action):
715
698
        return self._this['path']
716
699
 
756
739
 
757
740
    def test_take_this(self):
758
741
        self.run_script("""
759
 
$ bzr rm -q dir --no-backup
 
742
$ bzr rm -q dir  --force
760
743
$ bzr resolve dir
761
 
2>2 conflicts resolved, 0 remaining
 
744
2>2 conflict(s) resolved, 0 remaining
762
745
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
763
746
""")
764
747
 
765
748
    def test_take_other(self):
766
749
        self.run_script("""
767
750
$ bzr resolve dir
768
 
2>2 conflicts resolved, 0 remaining
 
751
2>2 conflict(s) resolved, 0 remaining
769
752
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
770
753
""")
771
754
 
785
768
$ bzr commit -q -m 'Add dir/file2 in branch'
786
769
$ bzr branch -q . -r 1 ../branch
787
770
$ cd ../branch
788
 
$ bzr rm -q dir/file --no-backup
 
771
$ bzr rm -q dir/file --force
789
772
$ bzr rm -q dir
790
773
$ bzr commit -q -m 'Remove dir/file'
791
774
$ bzr merge ../trunk
799
782
    def test_keep_them_all(self):
800
783
        self.run_script("""
801
784
$ bzr resolve dir
802
 
2>2 conflicts resolved, 0 remaining
 
785
2>2 conflict(s) resolved, 0 remaining
803
786
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
804
787
""")
805
788
 
806
789
    def test_adopt_child(self):
807
790
        self.run_script("""
808
791
$ bzr mv -q dir/file2 file2
809
 
$ bzr rm -q dir --no-backup
 
792
$ bzr rm -q dir --force
810
793
$ bzr resolve dir
811
 
2>2 conflicts resolved, 0 remaining
 
794
2>2 conflict(s) resolved, 0 remaining
812
795
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
813
796
""")
814
797
 
815
798
    def test_kill_them_all(self):
816
799
        self.run_script("""
817
 
$ bzr rm -q dir --no-backup
 
800
$ bzr rm -q dir --force
818
801
$ bzr resolve dir
819
 
2>2 conflicts resolved, 0 remaining
 
802
2>2 conflict(s) resolved, 0 remaining
820
803
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
821
804
""")
822
805
 
845
828
$ echo 'trunk content' >dir/file
846
829
$ bzr add -q
847
830
$ bzr commit -m 'Create trunk' -q
848
 
$ bzr rm -q dir/file --no-backup
849
 
$ bzr rm -q dir --no-backup
 
831
$ bzr rm -q dir/file --force
 
832
$ bzr rm -q dir --force
850
833
$ bzr commit -q -m 'Remove dir/file'
851
834
$ bzr branch -q . -r 1 ../branch
852
835
$ cd ../branch
863
846
    def test_keep_them_all(self):
864
847
        self.run_script("""
865
848
$ bzr resolve dir
866
 
2>2 conflicts resolved, 0 remaining
 
849
2>2 conflict(s) resolved, 0 remaining
867
850
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
868
851
""")
869
852
 
870
853
    def test_adopt_child(self):
871
854
        self.run_script("""
872
855
$ bzr mv -q dir/file2 file2
873
 
$ bzr rm -q dir --no-backup
 
856
$ bzr rm -q dir --force
874
857
$ bzr resolve dir
875
 
2>2 conflicts resolved, 0 remaining
 
858
2>2 conflict(s) resolved, 0 remaining
876
859
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
877
860
""")
878
861
 
879
862
    def test_kill_them_all(self):
880
863
        self.run_script("""
881
 
$ bzr rm -q dir --no-backup
 
864
$ bzr rm -q dir --force
882
865
$ bzr resolve dir
883
 
2>2 conflicts resolved, 0 remaining
 
866
2>2 conflict(s) resolved, 0 remaining
884
867
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
885
868
""")
886
869
 
887
870
    def test_resolve_taking_this(self):
888
871
        self.run_script("""
889
872
$ bzr resolve --take-this dir
890
 
2>2 conflicts resolved, 0 remaining
 
873
2>2 conflict(s) resolved, 0 remaining
891
874
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
892
875
""")
893
876
 
896
879
$ bzr resolve --take-other dir
897
880
2>deleted dir/file2
898
881
2>deleted dir
899
 
2>2 conflicts resolved, 0 remaining
 
882
2>2 conflict(s) resolved, 0 remaining
900
883
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
901
884
""")
902
885
 
988
971
        if self._other['xfail']:
989
972
            # It's a bit hackish to raise from here relying on being called for
990
973
            # both tests but this avoid overriding test_resolve_taking_other
991
 
            self.knownFailure(
 
974
            raise tests.KnownFailure(
992
975
                "ParentLoop doesn't carry enough info to resolve --take-other")
993
976
    _assert_conflict = assertParentLoop
994
977
 
1021
1004
 
1022
1005
    def test_take_this(self):
1023
1006
        self.run_script("""
1024
 
$ bzr rm -q foo.new --no-backup
 
1007
$ bzr rm -q foo.new --force
1025
1008
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
1026
1009
# aside ? -- vila 090916
1027
1010
$ bzr add -q foo
1028
1011
$ bzr resolve foo.new
1029
 
2>1 conflict resolved, 0 remaining
 
1012
2>1 conflict(s) resolved, 0 remaining
1030
1013
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1031
1014
""")
1032
1015
 
1033
1016
    def test_take_other(self):
1034
1017
        self.run_script("""
1035
 
$ bzr rm -q foo --no-backup
 
1018
$ bzr rm -q foo --force
1036
1019
$ bzr mv -q foo.new foo
1037
1020
$ bzr resolve foo
1038
 
2>1 conflict resolved, 0 remaining
 
1021
2>1 conflict(s) resolved, 0 remaining
1039
1022
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1040
1023
""")
1041
1024
 
1060
1043
        # This is nearly like TestResolveNonDirectoryParent but with branch and
1061
1044
        # trunk switched. As such it should certainly produce the same
1062
1045
        # conflict.
1063
 
        self.assertRaises(errors.MalformedTransform,
1064
 
                          self.run_script,"""
 
1046
        self.run_script("""
1065
1047
$ bzr init trunk
1066
1048
...
1067
1049
$ cd trunk
1081
1063
""")
1082
1064
 
1083
1065
 
1084
 
class TestNoFinalPath(script.TestCaseWithTransportAndScript):
1085
 
 
1086
 
    def test_bug_805809(self):
1087
 
        self.run_script("""
1088
 
$ bzr init trunk
1089
 
Created a standalone tree (format: 2a)
1090
 
$ cd trunk
1091
 
$ echo trunk >file
1092
 
$ bzr add
1093
 
adding file
1094
 
$ bzr commit -m 'create file on trunk'
1095
 
2>Committing to: .../trunk/
1096
 
2>added file
1097
 
2>Committed revision 1.
1098
 
# Create a debian branch based on trunk
1099
 
$ cd ..
1100
 
$ bzr branch trunk -r 1 debian
1101
 
2>Branched 1 revision.
1102
 
$ cd debian
1103
 
$ mkdir dir
1104
 
$ bzr add
1105
 
adding dir
1106
 
$ bzr mv file dir
1107
 
file => dir/file
1108
 
$ bzr commit -m 'rename file to dir/file for debian'
1109
 
2>Committing to: .../debian/
1110
 
2>added dir
1111
 
2>renamed file => dir/file
1112
 
2>Committed revision 2.
1113
 
# Create an experimental branch with a new root-id
1114
 
$ cd ..
1115
 
$ bzr init experimental
1116
 
Created a standalone tree (format: 2a)
1117
 
$ cd experimental
1118
 
# Work around merging into empty branch not being supported
1119
 
# (http://pad.lv/308562)
1120
 
$ echo something >not-empty
1121
 
$ bzr add
1122
 
adding not-empty
1123
 
$ bzr commit -m 'Add some content in experimental'
1124
 
2>Committing to: .../experimental/
1125
 
2>added not-empty
1126
 
2>Committed revision 1.
1127
 
# merge debian even without a common ancestor
1128
 
$ bzr merge ../debian -r0..2
1129
 
2>+N  dir/
1130
 
2>+N  dir/file
1131
 
2>All changes applied successfully.
1132
 
$ bzr commit -m 'merging debian into experimental'
1133
 
2>Committing to: .../experimental/
1134
 
2>added dir
1135
 
2>added dir/file
1136
 
2>Committed revision 2.
1137
 
# Create an ubuntu branch with yet another root-id
1138
 
$ cd ..
1139
 
$ bzr init ubuntu
1140
 
Created a standalone tree (format: 2a)
1141
 
$ cd ubuntu
1142
 
# Work around merging into empty branch not being supported
1143
 
# (http://pad.lv/308562)
1144
 
$ echo something >not-empty-ubuntu
1145
 
$ bzr add
1146
 
adding not-empty-ubuntu
1147
 
$ bzr commit -m 'Add some content in experimental'
1148
 
2>Committing to: .../ubuntu/
1149
 
2>added not-empty-ubuntu
1150
 
2>Committed revision 1.
1151
 
# Also merge debian
1152
 
$ bzr merge ../debian -r0..2
1153
 
2>+N  dir/
1154
 
2>+N  dir/file
1155
 
2>All changes applied successfully.
1156
 
$ bzr commit -m 'merging debian'
1157
 
2>Committing to: .../ubuntu/
1158
 
2>added dir
1159
 
2>added dir/file
1160
 
2>Committed revision 2.
1161
 
# Now try to merge experimental
1162
 
$ bzr merge ../experimental
1163
 
2>+N  not-empty
1164
 
2>Path conflict: dir / dir
1165
 
2>1 conflicts encountered.
1166
 
""")
1167
 
 
1168
 
 
1169
1066
class TestResolveActionOption(tests.TestCase):
1170
1067
 
1171
1068
    def setUp(self):