~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_conflicts.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-13 17:25:29 UTC
  • mfrom: (6499 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6501.
  • Revision ID: v.ladeuil+lp@free.fr-20120313172529-i0suyjnepsor25i7
Merge trunk

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
 
741
758
        self.run_script("""
742
759
$ bzr rm -q dir  --force
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
 
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
 
791
808
$ bzr mv -q dir/file2 file2
792
809
$ bzr rm -q dir --force
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
 
799
816
        self.run_script("""
800
817
$ bzr rm -q dir --force
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
 
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
 
855
872
$ bzr mv -q dir/file2 file2
856
873
$ bzr rm -q dir --force
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
 
863
880
        self.run_script("""
864
881
$ bzr rm -q dir --force
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
 
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
 
1018
1035
$ bzr rm -q foo --force
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
1080
1098
# Create a debian branch based on trunk
1081
1099
$ cd ..
1082
1100
$ bzr branch trunk -r 1 debian
1083
 
2>Branched 1 revision(s).
 
1101
2>Branched 1 revision.
1084
1102
$ cd debian
1085
1103
$ mkdir dir
1086
1104
$ bzr add