~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_conflicts.py

  • Committer: Patch Queue Manager
  • Date: 2015-04-21 05:32:33 UTC
  • mfrom: (6602.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20150421053233-x63rhby1q3612v2h
(richard-wilbur) (jelmer)Make bzr build reproducible for Debian. (Jelmer
 Vernooij)

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,
22
21
    conflicts,
23
22
    errors,
24
23
    option,
677
676
             ('fileb_created',
678
677
              dict(actions='create_file_b', check='file_content_b',
679
678
                   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')),),
680
687
            ])
681
688
 
682
689
    def do_nothing(self):
694
701
    def check_file_content_b(self):
695
702
        self.assertFileEqual('file b content\n', 'branch/file')
696
703
 
 
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
 
697
714
    def _get_resolve_path_arg(self, wt, action):
698
715
        return self._this['path']
699
716
 
739
756
 
740
757
    def test_take_this(self):
741
758
        self.run_script("""
742
 
$ bzr rm -q dir  --force
 
759
$ bzr rm -q dir --no-backup
743
760
$ bzr resolve dir
744
 
2>2 conflict(s) resolved, 0 remaining
 
761
2>2 conflicts resolved, 0 remaining
745
762
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
746
763
""")
747
764
 
748
765
    def test_take_other(self):
749
766
        self.run_script("""
750
767
$ bzr resolve dir
751
 
2>2 conflict(s) resolved, 0 remaining
 
768
2>2 conflicts resolved, 0 remaining
752
769
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
753
770
""")
754
771
 
768
785
$ bzr commit -q -m 'Add dir/file2 in branch'
769
786
$ bzr branch -q . -r 1 ../branch
770
787
$ cd ../branch
771
 
$ bzr rm -q dir/file --force
 
788
$ bzr rm -q dir/file --no-backup
772
789
$ bzr rm -q dir
773
790
$ bzr commit -q -m 'Remove dir/file'
774
791
$ bzr merge ../trunk
782
799
    def test_keep_them_all(self):
783
800
        self.run_script("""
784
801
$ bzr resolve dir
785
 
2>2 conflict(s) resolved, 0 remaining
 
802
2>2 conflicts resolved, 0 remaining
786
803
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
787
804
""")
788
805
 
789
806
    def test_adopt_child(self):
790
807
        self.run_script("""
791
808
$ bzr mv -q dir/file2 file2
792
 
$ bzr rm -q dir --force
 
809
$ bzr rm -q dir --no-backup
793
810
$ bzr resolve dir
794
 
2>2 conflict(s) resolved, 0 remaining
 
811
2>2 conflicts resolved, 0 remaining
795
812
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
796
813
""")
797
814
 
798
815
    def test_kill_them_all(self):
799
816
        self.run_script("""
800
 
$ bzr rm -q dir --force
 
817
$ bzr rm -q dir --no-backup
801
818
$ bzr resolve dir
802
 
2>2 conflict(s) resolved, 0 remaining
 
819
2>2 conflicts resolved, 0 remaining
803
820
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
804
821
""")
805
822
 
828
845
$ echo 'trunk content' >dir/file
829
846
$ bzr add -q
830
847
$ bzr commit -m 'Create trunk' -q
831
 
$ bzr rm -q dir/file --force
832
 
$ bzr rm -q dir --force
 
848
$ bzr rm -q dir/file --no-backup
 
849
$ bzr rm -q dir --no-backup
833
850
$ bzr commit -q -m 'Remove dir/file'
834
851
$ bzr branch -q . -r 1 ../branch
835
852
$ cd ../branch
846
863
    def test_keep_them_all(self):
847
864
        self.run_script("""
848
865
$ bzr resolve dir
849
 
2>2 conflict(s) resolved, 0 remaining
 
866
2>2 conflicts resolved, 0 remaining
850
867
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
851
868
""")
852
869
 
853
870
    def test_adopt_child(self):
854
871
        self.run_script("""
855
872
$ bzr mv -q dir/file2 file2
856
 
$ bzr rm -q dir --force
 
873
$ bzr rm -q dir --no-backup
857
874
$ bzr resolve dir
858
 
2>2 conflict(s) resolved, 0 remaining
 
875
2>2 conflicts resolved, 0 remaining
859
876
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
860
877
""")
861
878
 
862
879
    def test_kill_them_all(self):
863
880
        self.run_script("""
864
 
$ bzr rm -q dir --force
 
881
$ bzr rm -q dir --no-backup
865
882
$ bzr resolve dir
866
 
2>2 conflict(s) resolved, 0 remaining
 
883
2>2 conflicts resolved, 0 remaining
867
884
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
868
885
""")
869
886
 
870
887
    def test_resolve_taking_this(self):
871
888
        self.run_script("""
872
889
$ bzr resolve --take-this dir
873
 
2>2 conflict(s) resolved, 0 remaining
 
890
2>2 conflicts resolved, 0 remaining
874
891
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
875
892
""")
876
893
 
879
896
$ bzr resolve --take-other dir
880
897
2>deleted dir/file2
881
898
2>deleted dir
882
 
2>2 conflict(s) resolved, 0 remaining
 
899
2>2 conflicts resolved, 0 remaining
883
900
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
884
901
""")
885
902
 
971
988
        if self._other['xfail']:
972
989
            # It's a bit hackish to raise from here relying on being called for
973
990
            # both tests but this avoid overriding test_resolve_taking_other
974
 
            raise tests.KnownFailure(
 
991
            self.knownFailure(
975
992
                "ParentLoop doesn't carry enough info to resolve --take-other")
976
993
    _assert_conflict = assertParentLoop
977
994
 
1004
1021
 
1005
1022
    def test_take_this(self):
1006
1023
        self.run_script("""
1007
 
$ bzr rm -q foo.new --force
 
1024
$ bzr rm -q foo.new --no-backup
1008
1025
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
1009
1026
# aside ? -- vila 090916
1010
1027
$ bzr add -q foo
1011
1028
$ bzr resolve foo.new
1012
 
2>1 conflict(s) resolved, 0 remaining
 
1029
2>1 conflict resolved, 0 remaining
1013
1030
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1014
1031
""")
1015
1032
 
1016
1033
    def test_take_other(self):
1017
1034
        self.run_script("""
1018
 
$ bzr rm -q foo --force
 
1035
$ bzr rm -q foo --no-backup
1019
1036
$ bzr mv -q foo.new foo
1020
1037
$ bzr resolve foo
1021
 
2>1 conflict(s) resolved, 0 remaining
 
1038
2>1 conflict resolved, 0 remaining
1022
1039
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1023
1040
""")
1024
1041
 
1043
1060
        # This is nearly like TestResolveNonDirectoryParent but with branch and
1044
1061
        # trunk switched. As such it should certainly produce the same
1045
1062
        # conflict.
1046
 
        self.run_script("""
 
1063
        self.assertRaises(errors.MalformedTransform,
 
1064
                          self.run_script,"""
1047
1065
$ bzr init trunk
1048
1066
...
1049
1067
$ cd trunk
1063
1081
""")
1064
1082
 
1065
1083
 
 
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
 
1066
1169
class TestResolveActionOption(tests.TestCase):
1067
1170
 
1068
1171
    def setUp(self):