29
from bzrlib.tests import script
32
def load_tests(standard_tests, module, loader):
33
result = loader.suiteClass()
35
sp_tests, remaining_tests = tests.split_suite_by_condition(
36
standard_tests, tests.condition_isinstance((
37
TestParametrizedResolveConflicts,
39
# Each test class defines its own scenarios. This is needed for
40
# TestResolvePathConflictBefore531967 that verifies that the same tests as
41
# TestResolvePathConflict still pass.
42
for test in tests.iter_suite_tests(sp_tests):
43
tests.apply_scenarios(test, test.scenarios(), result)
45
# No parametrization for the remaining tests
46
result.addTests(remaining_tests)
29
from bzrlib.tests import (
35
load_tests = scenarios.load_tests_apply_scenarios
51
38
# TODO: Test commit with some added, and added-but-missing files
298
"""Return the scenario list for the conflict type defined by the class.
300
Each scenario is of the form:
301
(common, (left_name, left_dict), (right_name, right_dict))
305
* left_name and right_name are the scenario names that will be combined
307
* left_dict and right_dict are the attributes specific to each half of
308
the scenario. They should include at least 'actions' and 'check' and
309
will be available as '_this' and '_other' test instance attributes.
311
Daughters classes are free to add their specific attributes as they see
312
fit in any of the three dicts.
314
This is a class method so that load_tests can find it.
316
'_base_actions' in the common dict, 'actions' and 'check' in the left
317
and right dicts use names that map to methods in the test classes. Some
318
prefixes are added to these names to get the correspong methods (see
319
_get_actions() and _get_check()). The motivation here is to avoid
320
collisions in the class namespace.
322
# Only concrete classes return actual scenarios
279
"""The scenario list for the conflict type defined by the class.
281
Each scenario is of the form:
282
(common, (left_name, left_dict), (right_name, right_dict))
286
* left_name and right_name are the scenario names that will be combined
288
* left_dict and right_dict are the attributes specific to each half of
289
the scenario. They should include at least 'actions' and 'check' and
290
will be available as '_this' and '_other' test instance attributes.
292
Daughters classes are free to add their specific attributes as they see
293
fit in any of the three dicts.
295
This is a class method so that load_tests can find it.
297
'_base_actions' in the common dict, 'actions' and 'check' in the left
298
and right dicts use names that map to methods in the test classes. Some
299
prefixes are added to these names to get the correspong methods (see
300
_get_actions() and _get_check()). The motivation here is to avoid
301
collisions in the class namespace.
326
305
super(TestParametrizedResolveConflicts, self).setUp()
370
class TestResolveTextConflicts(TestParametrizedResolveConflicts):
372
_conflict_type = conflicts.TextConflict
374
# Set by the scenarios
375
# path and file-id for the file involved in the conflict
379
scenarios = mirror_scenarios(
381
# File modified/deleted
382
(dict(_base_actions='create_file',
383
_path='file', _file_id='file-id'),
385
dict(actions='modify_file_A', check='file_has_content_A')),
387
dict(actions='modify_file_B', check='file_has_content_B')),),
390
def do_create_file(self):
391
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
393
def do_modify_file_A(self):
394
return [('modify', ('file-id', 'trunk content\nfeature A\n'))]
396
def do_modify_file_B(self):
397
return [('modify', ('file-id', 'trunk content\nfeature B\n'))]
399
def check_file_has_content_A(self):
400
self.assertFileEqual('trunk content\nfeature A\n', 'branch/file')
402
def check_file_has_content_B(self):
403
self.assertFileEqual('trunk content\nfeature B\n', 'branch/file')
405
def _get_resolve_path_arg(self, wt, action):
408
def assertTextConflict(self, wt, c):
409
self.assertEqual(self._file_id, c.file_id)
410
self.assertEqual(self._path, c.path)
411
_assert_conflict = assertTextConflict
391
414
class TestResolveContentsConflict(TestParametrizedResolveConflicts):
393
_conflict_type = conflicts.ContentsConflict,
416
_conflict_type = conflicts.ContentsConflict
395
# Set by load_tests from scenarios()
418
# Set by the scenarios
396
419
# path and file-id for the file involved in the conflict
423
scenarios = mirror_scenarios(
403
425
# File modified/deleted
404
426
(dict(_base_actions='create_file',
405
427
_path='file', _file_id='file-id'),
407
429
dict(actions='modify_file', check='file_has_more_content')),
409
431
dict(actions='delete_file', check='file_doesnt_exist')),),
411
return mirror_scenarios(base_scenarios)
413
434
def do_create_file(self):
414
435
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
437
458
class TestResolvePathConflict(TestParametrizedResolveConflicts):
439
_conflict_type = conflicts.PathConflict,
460
_conflict_type = conflicts.PathConflict
441
462
def do_nothing(self):
446
# Each side dict additionally defines:
447
# - path path involved (can be '<deleted>')
465
# Each side dict additionally defines:
466
# - path path involved (can be '<deleted>')
468
scenarios = mirror_scenarios(
450
470
# File renamed/deleted
451
471
(dict(_base_actions='create_file'),
484
504
dict(actions='rename_dir2', check='dir_renamed2',
485
505
path='new-dir2', file_id='dir-id')),),
487
return mirror_scenarios(base_scenarios)
489
508
def do_create_file(self):
490
509
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
569
588
class TestResolveDuplicateEntry(TestParametrizedResolveConflicts):
571
_conflict_type = conflicts.DuplicateEntry,
590
_conflict_type = conflicts.DuplicateEntry
575
# Each side dict additionally defines:
592
scenarios = mirror_scenarios(
579
594
# File created with different file-ids
580
595
(dict(_base_actions='nothing'),
581
596
('filea_created',
625
639
# tests MissingParent resolution :-/
631
$ bzr commit -m 'Create trunk'
646
$ bzr commit -m 'Create trunk' -q
633
647
$ echo 'trunk content' >dir/file
635
$ bzr commit -m 'Add dir/file in trunk'
637
$ bzr branch . -r 1 ../branch
648
$ bzr add -q dir/file
649
$ bzr commit -q -m 'Add dir/file in trunk'
650
$ bzr branch -q . -r 1 ../branch
640
$ bzr commit -m 'Remove dir in branch'
653
$ bzr commit -q -m 'Remove dir in branch'
642
654
$ bzr merge ../trunk
650
662
def test_take_this(self):
651
663
self.run_script("""
664
$ bzr rm -q dir --force
653
665
$ bzr resolve dir
654
$ bzr commit --strict -m 'No more conflicts nor unknown files'
666
2>2 conflict(s) resolved, 0 remaining
667
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
657
670
def test_take_other(self):
658
671
self.run_script("""
659
672
$ bzr resolve dir
660
$ bzr commit --strict -m 'No more conflicts nor unknown files'
673
2>2 conflict(s) resolved, 0 remaining
674
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
670
685
$ echo 'trunk content' >dir/file
672
$ bzr commit -m 'Create trunk'
687
$ bzr commit -m 'Create trunk' -q
674
688
$ echo 'trunk content' >dir/file2
676
$ bzr commit -m 'Add dir/file2 in branch'
678
$ bzr branch . -r 1 ../branch
689
$ bzr add -q dir/file2
690
$ bzr commit -q -m 'Add dir/file2 in branch'
691
$ bzr branch -q . -r 1 ../branch
680
$ bzr rm dir/file --force
682
$ bzr commit -m 'Remove dir/file'
693
$ bzr rm -q dir/file --force
695
$ bzr commit -q -m 'Remove dir/file'
684
696
$ bzr merge ../trunk
692
704
def test_keep_them_all(self):
693
705
self.run_script("""
694
706
$ bzr resolve dir
695
$ bzr commit --strict -m 'No more conflicts nor unknown files'
707
2>2 conflict(s) resolved, 0 remaining
708
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
698
711
def test_adopt_child(self):
699
712
self.run_script("""
700
$ bzr mv dir/file2 file2
713
$ bzr mv -q dir/file2 file2
714
$ bzr rm -q dir --force
702
715
$ bzr resolve dir
703
$ bzr commit --strict -m 'No more conflicts nor unknown files'
716
2>2 conflict(s) resolved, 0 remaining
717
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
706
720
def test_kill_them_all(self):
707
721
self.run_script("""
722
$ bzr rm -q dir --force
709
723
$ bzr resolve dir
710
$ bzr commit --strict -m 'No more conflicts nor unknown files'
724
2>2 conflict(s) resolved, 0 remaining
725
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
713
728
def test_resolve_taking_this(self):
714
729
self.run_script("""
715
730
$ bzr resolve --take-this dir
716
$ bzr commit --strict -m 'No more conflicts nor unknown files'
732
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
719
735
def test_resolve_taking_other(self):
720
736
self.run_script("""
721
737
$ bzr resolve --take-other dir
722
$ bzr commit --strict -m 'No more conflicts nor unknown files'
739
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
732
750
$ echo 'trunk content' >dir/file
734
$ bzr commit -m 'Create trunk'
736
$ bzr rm dir/file --force
738
$ bzr commit -m 'Remove dir/file'
740
$ bzr branch . -r 1 ../branch
752
$ bzr commit -m 'Create trunk' -q
753
$ bzr rm -q dir/file --force
754
$ bzr rm -q dir --force
755
$ bzr commit -q -m 'Remove dir/file'
756
$ bzr branch -q . -r 1 ../branch
742
758
$ echo 'branch content' >dir/file2
744
$ bzr commit -m 'Add dir/file2 in branch'
759
$ bzr add -q dir/file2
760
$ bzr commit -q -m 'Add dir/file2 in branch'
746
761
$ bzr merge ../trunk
748
763
2>Conflict: can't delete dir because it is not empty. Not deleting.
753
768
def test_keep_them_all(self):
754
769
self.run_script("""
755
770
$ bzr resolve dir
756
$ bzr commit --strict -m 'No more conflicts nor unknown files'
771
2>2 conflict(s) resolved, 0 remaining
772
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
759
775
def test_adopt_child(self):
760
776
self.run_script("""
761
$ bzr mv dir/file2 file2
777
$ bzr mv -q dir/file2 file2
778
$ bzr rm -q dir --force
763
779
$ bzr resolve dir
764
$ bzr commit --strict -m 'No more conflicts nor unknown files'
780
2>2 conflict(s) resolved, 0 remaining
781
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
767
784
def test_kill_them_all(self):
768
785
self.run_script("""
786
$ bzr rm -q dir --force
770
787
$ bzr resolve dir
771
$ bzr commit --strict -m 'No more conflicts nor unknown files'
788
2>2 conflict(s) resolved, 0 remaining
789
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
774
792
def test_resolve_taking_this(self):
775
793
self.run_script("""
776
794
$ bzr resolve --take-this dir
777
$ bzr commit --strict -m 'No more conflicts nor unknown files'
795
2>2 conflict(s) resolved, 0 remaining
796
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
780
799
def test_resolve_taking_other(self):
781
800
self.run_script("""
782
801
$ bzr resolve --take-other dir
783
$ bzr commit --strict -m 'No more conflicts nor unknown files'
804
2>2 conflict(s) resolved, 0 remaining
805
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
787
809
class TestResolveParentLoop(TestParametrizedResolveConflicts):
789
_conflict_type = conflicts.ParentLoop,
811
_conflict_type = conflicts.ParentLoop
791
813
_this_args = None
792
814
_other_args = None
796
# Each side dict additionally defines:
797
# - dir_id: the directory being moved
798
# - target_id: The target directory
799
# - xfail: whether the test is expected to fail if the action is
800
# involved as 'other'
816
# Each side dict additionally defines:
817
# - dir_id: the directory being moved
818
# - target_id: The target directory
819
# - xfail: whether the test is expected to fail if the action is
820
# involved as 'other'
821
scenarios = mirror_scenarios(
802
823
# Dirs moved into each other
803
824
(dict(_base_actions='create_dir1_dir2'),
804
825
('dir1_into_dir2',
815
836
('dir3_into_dir2',
816
837
dict(actions='move_dir3_into_dir2', check='dir3_4_moved',
817
838
dir_id='dir3-id', target_id='dir2-id', xfail=True))),
819
return mirror_scenarios(base_scenarios)
821
841
def do_create_dir1_dir2(self):
822
842
return [('add', ('dir1', 'dir1-id', 'directory', '')),
887
$ bzr commit -m 'Create trunk'
909
$ bzr commit -m 'Create trunk' -q
888
910
$ echo "Boing" >foo/bar
890
$ bzr commit -m 'Add foo/bar'
892
$ bzr branch . -r 1 ../branch
912
$ bzr commit -q -m 'Add foo/bar'
913
$ bzr branch -q . -r 1 ../branch
895
916
$ echo "Boo!" >foo
896
$ bzr commit -m 'foo is now a file'
917
$ bzr commit -q -m 'foo is now a file'
898
918
$ bzr merge ../trunk
900
920
2>RK foo => foo.new/
907
927
def test_take_this(self):
908
928
self.run_script("""
909
$ bzr rm foo.new --force
929
$ bzr rm -q foo.new --force
910
930
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
911
931
# aside ? -- vila 090916
913
933
$ bzr resolve foo.new
914
$ bzr commit --strict -m 'No more conflicts nor unknown files'
934
2>1 conflict(s) resolved, 0 remaining
935
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
917
938
def test_take_other(self):
918
939
self.run_script("""
940
$ bzr rm -q foo --force
941
$ bzr mv -q foo.new foo
921
942
$ bzr resolve foo
922
$ bzr commit --strict -m 'No more conflicts nor unknown files'
943
2>1 conflict(s) resolved, 0 remaining
944
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
925
947
def test_resolve_taking_this(self):
926
948
self.run_script("""
927
949
$ bzr resolve --take-this foo.new
928
$ bzr commit --strict -m 'No more conflicts nor unknown files'
951
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
931
954
def test_resolve_taking_other(self):
932
955
self.run_script("""
933
956
$ bzr resolve --take-other foo.new
934
$ bzr commit --strict -m 'No more conflicts nor unknown files'
958
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
944
968
self.run_script("""
948
$ bzr commit -m 'Create trunk'
974
$ bzr commit -m 'Create trunk' -q
950
976
$ echo "Boo!" >foo
951
$ bzr commit -m 'foo is now a file'
953
$ bzr branch . -r 1 ../branch
977
$ bzr commit -m 'foo is now a file' -q
978
$ bzr branch -q . -r 1 ../branch -q
955
980
$ echo "Boing" >foo/bar
957
$ bzr commit -m 'Add foo/bar'
981
$ bzr add -q foo/bar -q
982
$ bzr commit -m 'Add foo/bar' -q
959
983
$ bzr merge ../trunk
960
984
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]