71
71
def test_resolve_conflict_dir(self):
72
72
tree = self.make_branch_and_tree('.')
73
self.build_tree_contents([('hello', b'hello world4'),
74
('hello.THIS', b'hello world2'),
75
('hello.BASE', b'hello world1'),
73
self.build_tree_contents([('hello', 'hello world4'),
74
('hello.THIS', 'hello world2'),
75
('hello.BASE', 'hello world1'),
77
77
os.mkdir('hello.OTHER')
78
78
tree.add('hello', 'q')
302
302
builder.start_series()
304
304
# Create an empty trunk
305
builder.build_snapshot(None, [
306
('add', ('', 'root-id', 'directory', ''))],
305
builder.build_snapshot('start', None, [
306
('add', ('', 'root-id', 'directory', ''))])
308
307
# Add a minimal base content
309
308
base_actions = self._get_actions(self._base_actions)()
310
builder.build_snapshot(['start'], base_actions, revision_id='base')
309
builder.build_snapshot('base', ['start'], base_actions)
311
310
# Modify the base content in branch
312
311
actions_other = self._get_actions(self._other['actions'])()
313
builder.build_snapshot(['base'], actions_other, revision_id='other')
312
builder.build_snapshot('other', ['base'], actions_other)
314
313
# Modify the base content in trunk
315
314
actions_this = self._get_actions(self._this['actions'])()
316
builder.build_snapshot(['base'], actions_this, revision_id='this')
315
builder.build_snapshot('this', ['base'], actions_this)
317
316
# builder.get_branch() tip is now 'this'
319
318
builder.finish_series()
385
384
(dict(_base_actions='create_file_in_dir',
386
385
_path='dir/file', _file_id='file-id'),
387
386
('filed_modified_A_in_dir',
388
dict(actions='modify_file_A_in_dir',
387
dict(actions='modify_file_A',
389
388
check='file_in_dir_has_content_A')),
390
389
('file_modified_B',
391
dict(actions='modify_file_B_in_dir',
390
dict(actions='modify_file_B',
392
391
check='file_in_dir_has_content_B')),),
396
395
return [('add', (path, 'file-id', 'file', 'trunk content\n'))]
398
397
def do_modify_file_A(self):
399
return [('modify', ('file', 'trunk content\nfeature A\n'))]
398
return [('modify', ('file-id', 'trunk content\nfeature A\n'))]
401
400
def do_modify_file_B(self):
402
return [('modify', ('file', 'trunk content\nfeature B\n'))]
404
def do_modify_file_A_in_dir(self):
405
return [('modify', ('dir/file', 'trunk content\nfeature A\n'))]
407
def do_modify_file_B_in_dir(self):
408
return [('modify', ('dir/file', 'trunk content\nfeature B\n'))]
401
return [('modify', ('file-id', 'trunk content\nfeature B\n'))]
410
403
def check_file_has_content_A(self, path='file'):
411
404
self.assertFileEqual('trunk content\nfeature A\n',
467
460
dict(actions='modify_file_in_dir',
468
461
check='file_in_dir_has_more_content')),
469
462
('file_deleted_in_dir',
470
dict(actions='delete_file_in_dir',
463
dict(actions='delete_file',
471
464
check='file_in_dir_doesnt_exist')),),
475
468
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
477
470
def do_modify_file(self):
478
return [('modify', ('file', 'trunk content\nmore content\n'))]
471
return [('modify', ('file-id', 'trunk content\nmore content\n'))]
480
473
def do_modify_and_rename_file(self):
481
return [('modify', ('new-file', 'trunk content\nmore content\n')),
474
return [('modify', ('file-id', 'trunk content\nmore content\n')),
482
475
('rename', ('file', 'new-file'))]
484
477
def check_file_has_more_content(self):
488
481
self.assertFileEqual('trunk content\nmore content\n', 'branch/new-file')
490
483
def do_delete_file(self):
491
return [('unversion', 'file')]
493
def do_delete_file_in_dir(self):
494
return [('unversion', 'dir/file')]
484
return [('unversion', 'file-id')]
496
486
def check_file_doesnt_exist(self):
497
487
self.assertPathDoesNotExist('branch/file')
501
491
('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
503
493
def do_modify_file_in_dir(self):
504
return [('modify', ('dir/file', 'trunk content\nmore content\n'))]
494
return [('modify', ('file-id', 'trunk content\nmore content\n'))]
506
496
def check_file_in_dir_has_more_content(self):
507
497
self.assertFileEqual('trunk content\nmore content\n', 'branch/dir/file')
546
536
dict(actions='rename_file_in_dir', check='file_in_dir_renamed',
547
537
path='dir/new-file', file_id='file-id')),
549
dict(actions='delete_file_in_dir', check='file_in_dir_doesnt_exist',
539
dict(actions='delete_file', check='file_in_dir_doesnt_exist',
550
540
# PathConflicts deletion handling requires a special
551
541
# hard-coded value
552
542
path='<deleted>', file_id='file-id')),),
613
603
self.assertPathExists('branch/new-dir2')
615
605
def do_delete_file(self):
616
return [('unversion', 'file')]
618
def do_delete_file_in_dir(self):
619
return [('unversion', 'dir/file')]
606
return [('unversion', 'file-id')]
621
608
def check_file_doesnt_exist(self):
622
609
self.assertPathDoesNotExist('branch/file')
624
611
def do_delete_dir(self):
625
return [('unversion', 'dir')]
612
return [('unversion', 'dir-id')]
627
614
def check_dir_doesnt_exist(self):
628
615
self.assertPathDoesNotExist('branch/dir')
715
702
self.assertFileEqual('file b content\n', 'branch/file')
717
704
def do_replace_file_a_by_b(self):
718
return [('unversion', 'file'),
705
return [('unversion', 'file-a-id'),
719
706
('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
721
708
def do_modify_file_a(self):
722
return [('modify', ('file', 'new content\n'))]
709
return [('modify', ('file-a-id', 'new content\n'))]
724
711
def check_file_new_content(self):
725
712
self.assertFileEqual('new content\n', 'branch/file')
746
733
# FIXME: While this *creates* UnversionedParent conflicts, this really only
747
734
# tests MissingParent resolution :-/
754
$ brz commit -m 'Create trunk' -q
741
$ bzr commit -m 'Create trunk' -q
755
742
$ echo 'trunk content' >dir/file
756
$ brz add -q dir/file
757
$ brz commit -q -m 'Add dir/file in trunk'
758
$ brz branch -q . -r 1 ../branch
743
$ bzr add -q dir/file
744
$ bzr commit -q -m 'Add dir/file in trunk'
745
$ bzr branch -q . -r 1 ../branch
761
$ brz commit -q -m 'Remove dir in branch'
748
$ bzr commit -q -m 'Remove dir in branch'
765
752
2>Conflict adding files to dir. Created directory.
770
757
def test_take_this(self):
771
758
self.run_script("""
772
$ brz rm -q dir --no-backup
759
$ bzr rm -q dir --no-backup
774
761
2>2 conflicts resolved, 0 remaining
775
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
762
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
778
765
def test_take_other(self):
779
766
self.run_script("""
781
768
2>2 conflicts resolved, 0 remaining
782
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
769
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
786
773
class TestResolveMissingParent(TestResolveConflicts):
793
780
$ echo 'trunk content' >dir/file
795
$ brz commit -m 'Create trunk' -q
782
$ bzr commit -m 'Create trunk' -q
796
783
$ echo 'trunk content' >dir/file2
797
$ brz add -q dir/file2
798
$ brz commit -q -m 'Add dir/file2 in branch'
799
$ brz branch -q . -r 1 ../branch
784
$ bzr add -q dir/file2
785
$ bzr commit -q -m 'Add dir/file2 in branch'
786
$ bzr branch -q . -r 1 ../branch
801
$ brz rm -q dir/file --no-backup
803
$ brz commit -q -m 'Remove dir/file'
788
$ bzr rm -q dir/file --no-backup
790
$ bzr commit -q -m 'Remove dir/file'
807
794
2>Conflict adding files to dir. Created directory.
812
799
def test_keep_them_all(self):
813
800
self.run_script("""
815
802
2>2 conflicts resolved, 0 remaining
816
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
803
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
819
806
def test_adopt_child(self):
820
807
self.run_script("""
821
$ brz mv -q dir/file2 file2
822
$ brz rm -q dir --no-backup
808
$ bzr mv -q dir/file2 file2
809
$ bzr rm -q dir --no-backup
824
811
2>2 conflicts resolved, 0 remaining
825
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
812
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
828
815
def test_kill_them_all(self):
829
816
self.run_script("""
830
$ brz rm -q dir --no-backup
817
$ bzr rm -q dir --no-backup
832
819
2>2 conflicts resolved, 0 remaining
833
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
820
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
836
823
def test_resolve_taking_this(self):
837
824
self.run_script("""
838
$ brz resolve --take-this dir
825
$ bzr resolve --take-this dir
840
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
827
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
843
830
def test_resolve_taking_other(self):
844
831
self.run_script("""
845
$ brz resolve --take-other dir
832
$ bzr resolve --take-other dir
847
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
834
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
851
838
class TestResolveDeletingParent(TestResolveConflicts):
858
845
$ echo 'trunk content' >dir/file
860
$ brz commit -m 'Create trunk' -q
861
$ brz rm -q dir/file --no-backup
862
$ brz rm -q dir --no-backup
863
$ brz commit -q -m 'Remove dir/file'
864
$ brz branch -q . -r 1 ../branch
847
$ bzr commit -m 'Create trunk' -q
848
$ bzr rm -q dir/file --no-backup
849
$ bzr rm -q dir --no-backup
850
$ bzr commit -q -m 'Remove dir/file'
851
$ bzr branch -q . -r 1 ../branch
866
853
$ echo 'branch content' >dir/file2
867
$ brz add -q dir/file2
868
$ brz commit -q -m 'Add dir/file2 in branch'
854
$ bzr add -q dir/file2
855
$ bzr commit -q -m 'Add dir/file2 in branch'
871
858
2>Conflict: can't delete dir because it is not empty. Not deleting.
872
859
2>Conflict because dir is not versioned, but has versioned children. Versioned directory.
876
863
def test_keep_them_all(self):
877
864
self.run_script("""
879
866
2>2 conflicts resolved, 0 remaining
880
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
867
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
883
870
def test_adopt_child(self):
884
871
self.run_script("""
885
$ brz mv -q dir/file2 file2
886
$ brz rm -q dir --no-backup
872
$ bzr mv -q dir/file2 file2
873
$ bzr rm -q dir --no-backup
888
875
2>2 conflicts resolved, 0 remaining
889
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
876
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
892
879
def test_kill_them_all(self):
893
880
self.run_script("""
894
$ brz rm -q dir --no-backup
881
$ bzr rm -q dir --no-backup
896
883
2>2 conflicts resolved, 0 remaining
897
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
884
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
900
887
def test_resolve_taking_this(self):
901
888
self.run_script("""
902
$ brz resolve --take-this dir
889
$ bzr resolve --take-this dir
903
890
2>2 conflicts resolved, 0 remaining
904
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
891
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
907
894
def test_resolve_taking_other(self):
908
895
self.run_script("""
909
$ brz resolve --take-other dir
896
$ bzr resolve --take-other dir
910
897
2>deleted dir/file2
912
899
2>2 conflicts resolved, 0 remaining
913
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
900
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1009
996
class TestResolveNonDirectoryParent(TestResolveConflicts):
1017
$ brz commit -m 'Create trunk' -q
1004
$ bzr commit -m 'Create trunk' -q
1018
1005
$ echo "Boing" >foo/bar
1019
$ brz add -q foo/bar
1020
$ brz commit -q -m 'Add foo/bar'
1021
$ brz branch -q . -r 1 ../branch
1006
$ bzr add -q foo/bar
1007
$ bzr commit -q -m 'Add foo/bar'
1008
$ bzr branch -q . -r 1 ../branch
1024
1011
$ echo "Boo!" >foo
1025
$ brz commit -q -m 'foo is now a file'
1026
$ brz merge ../trunk
1012
$ bzr commit -q -m 'foo is now a file'
1013
$ bzr merge ../trunk
1027
1014
2>+N foo.new/bar
1028
1015
2>RK foo => foo.new/
1029
1016
# FIXME: The message is misleading, foo.new *is* a directory when the message
1035
1022
def test_take_this(self):
1036
1023
self.run_script("""
1037
$ brz rm -q foo.new --no-backup
1024
$ bzr rm -q foo.new --no-backup
1038
1025
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
1039
1026
# aside ? -- vila 090916
1041
$ brz resolve foo.new
1028
$ bzr resolve foo.new
1042
1029
2>1 conflict resolved, 0 remaining
1043
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
1030
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1046
1033
def test_take_other(self):
1047
1034
self.run_script("""
1048
$ brz rm -q foo --no-backup
1049
$ brz mv -q foo.new foo
1035
$ bzr rm -q foo --no-backup
1036
$ bzr mv -q foo.new foo
1051
1038
2>1 conflict resolved, 0 remaining
1052
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
1039
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1055
1042
def test_resolve_taking_this(self):
1056
1043
self.run_script("""
1057
$ brz resolve --take-this foo.new
1044
$ bzr resolve --take-this foo.new
1059
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
1046
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1062
1049
def test_resolve_taking_other(self):
1063
1050
self.run_script("""
1064
$ brz resolve --take-other foo.new
1051
$ bzr resolve --take-other foo.new
1066
$ brz commit -q --strict -m 'No more conflicts nor unknown files'
1053
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1074
1061
# trunk switched. As such it should certainly produce the same
1076
1063
self.assertRaises(errors.MalformedTransform,
1077
self.run_script, """
1083
$ brz commit -m 'Create trunk' -q
1070
$ bzr commit -m 'Create trunk' -q
1085
1072
$ echo "Boo!" >foo
1086
$ brz commit -m 'foo is now a file' -q
1087
$ brz branch -q . -r 1 ../branch -q
1073
$ bzr commit -m 'foo is now a file' -q
1074
$ bzr branch -q . -r 1 ../branch -q
1089
1076
$ echo "Boing" >foo/bar
1090
$ brz add -q foo/bar -q
1091
$ brz commit -m 'Add foo/bar' -q
1092
$ brz merge ../trunk
1093
2>brz: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
1077
$ bzr add -q foo/bar -q
1078
$ bzr commit -m 'Add foo/bar' -q
1079
$ bzr merge ../trunk
1080
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
1099
1086
def test_bug_805809(self):
1100
1087
self.run_script("""
1102
1089
Created a standalone tree (format: 2a)
1104
1091
$ echo trunk >file
1107
$ brz commit -m 'create file on trunk'
1094
$ bzr commit -m 'create file on trunk'
1108
1095
2>Committing to: .../trunk/
1110
1097
2>Committed revision 1.
1111
1098
# Create a debian branch based on trunk
1113
$ brz branch trunk -r 1 debian
1100
$ bzr branch trunk -r 1 debian
1114
1101
2>Branched 1 revision.
1120
1107
file => dir/file
1121
$ brz commit -m 'rename file to dir/file for debian'
1108
$ bzr commit -m 'rename file to dir/file for debian'
1122
1109
2>Committing to: .../debian/
1124
1111
2>renamed file => dir/file
1125
1112
2>Committed revision 2.
1126
1113
# Create an experimental branch with a new root-id
1128
$ brz init experimental
1115
$ bzr init experimental
1129
1116
Created a standalone tree (format: 2a)
1130
1117
$ cd experimental
1131
1118
# Work around merging into empty branch not being supported
1132
1119
# (http://pad.lv/308562)
1133
1120
$ echo something >not-empty
1135
1122
adding not-empty
1136
$ brz commit -m 'Add some content in experimental'
1123
$ bzr commit -m 'Add some content in experimental'
1137
1124
2>Committing to: .../experimental/
1138
1125
2>added not-empty
1139
1126
2>Committed revision 1.
1140
1127
# merge debian even without a common ancestor
1141
$ brz merge ../debian -r0..2
1128
$ bzr merge ../debian -r0..2
1144
1131
2>All changes applied successfully.
1145
$ brz commit -m 'merging debian into experimental'
1132
$ bzr commit -m 'merging debian into experimental'
1146
1133
2>Committing to: .../experimental/
1148
1135
2>added dir/file
1149
1136
2>Committed revision 2.
1150
1137
# Create an ubuntu branch with yet another root-id
1153
1140
Created a standalone tree (format: 2a)
1155
1142
# Work around merging into empty branch not being supported
1156
1143
# (http://pad.lv/308562)
1157
1144
$ echo something >not-empty-ubuntu
1159
1146
adding not-empty-ubuntu
1160
$ brz commit -m 'Add some content in experimental'
1147
$ bzr commit -m 'Add some content in experimental'
1161
1148
2>Committing to: .../ubuntu/
1162
1149
2>added not-empty-ubuntu
1163
1150
2>Committed revision 1.
1164
1151
# Also merge debian
1165
$ brz merge ../debian -r0..2
1152
$ bzr merge ../debian -r0..2
1168
1155
2>All changes applied successfully.
1169
$ brz commit -m 'merging debian'
1156
$ bzr commit -m 'merging debian'
1170
1157
2>Committing to: .../ubuntu/
1172
1159
2>added dir/file
1173
1160
2>Committed revision 2.
1174
1161
# Now try to merge experimental
1175
$ brz merge ../experimental
1162
$ bzr merge ../experimental
1177
1164
2>Path conflict: dir / dir
1178
1165
2>1 conflicts encountered.
1191
1178
return self.parser.parse_args(args)
1193
1180
def test_unknown_action(self):
1194
self.assertRaises(option.BadOptionValue,
1181
self.assertRaises(errors.BadOptionValue,
1195
1182
self.parse, ['--action', 'take-me-to-the-moon'])
1197
1184
def test_done(self):