125
120
self.assertEqual(conflicts.ConflictList([]), tree.conflicts())
128
class TestPerConflict(tests.TestCase):
130
scenarios = scenarios.multiply_scenarios(vary_by_conflicts())
132
def test_stringification(self):
133
text = unicode(self.conflict)
134
self.assertContainsString(text, self.conflict.path)
135
self.assertContainsString(text.lower(), "conflict")
136
self.assertContainsString(repr(self.conflict),
137
self.conflict.__class__.__name__)
123
class TestConflictStanzas(tests.TestCase):
139
125
def test_stanza_roundtrip(self):
141
o = conflicts.Conflict.factory(**p.as_stanza().as_dict())
142
self.assertEqual(o, p)
144
self.assertIsInstance(o.path, unicode)
146
if o.file_id is not None:
147
self.assertIsInstance(o.file_id, str)
149
conflict_path = getattr(o, 'conflict_path', None)
150
if conflict_path is not None:
151
self.assertIsInstance(conflict_path, unicode)
153
conflict_file_id = getattr(o, 'conflict_file_id', None)
154
if conflict_file_id is not None:
155
self.assertIsInstance(conflict_file_id, str)
126
# write and read our example stanza.
127
stanza_iter = example_conflicts.to_stanzas()
128
processed = conflicts.ConflictList.from_stanzas(stanza_iter)
129
for o, p in zip(processed, example_conflicts):
130
self.assertEqual(o, p)
132
self.assertIsInstance(o.path, unicode)
134
if o.file_id is not None:
135
self.assertIsInstance(o.file_id, str)
137
conflict_path = getattr(o, 'conflict_path', None)
138
if conflict_path is not None:
139
self.assertIsInstance(conflict_path, unicode)
141
conflict_file_id = getattr(o, 'conflict_file_id', None)
142
if conflict_file_id is not None:
143
self.assertIsInstance(conflict_file_id, str)
157
145
def test_stanzification(self):
158
stanza = self.conflict.as_stanza()
159
if 'file_id' in stanza:
160
# In Stanza form, the file_id has to be unicode.
161
self.assertStartsWith(stanza['file_id'], u'\xeed')
162
self.assertStartsWith(stanza['path'], u'p\xe5th')
163
if 'conflict_path' in stanza:
164
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
165
if 'conflict_file_id' in stanza:
166
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
169
class TestConflictList(tests.TestCase):
171
def test_stanzas_roundtrip(self):
172
stanzas_iter = example_conflicts.to_stanzas()
173
processed = conflicts.ConflictList.from_stanzas(stanzas_iter)
174
self.assertEqual(example_conflicts, processed)
176
def test_stringification(self):
177
for text, o in zip(example_conflicts.to_strings(), example_conflicts):
178
self.assertEqual(text, unicode(o))
146
for stanza in example_conflicts.to_stanzas():
147
if 'file_id' in stanza:
148
# In Stanza form, the file_id has to be unicode.
149
self.assertStartsWith(stanza['file_id'], u'\xeed')
150
self.assertStartsWith(stanza['path'], u'p\xe5th')
151
if 'conflict_path' in stanza:
152
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
153
if 'conflict_file_id' in stanza:
154
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
181
157
# FIXME: The shell-like tests should be converted to real whitebox tests... or
446
422
dict(actions='modify_file', check='file_has_more_content')),
448
424
dict(actions='delete_file', check='file_doesnt_exist')),),
449
# File renamed-modified/deleted
450
(dict(_base_actions='create_file',
451
_path='new-file', _file_id='file-id'),
452
('file_renamed_and_modified',
453
dict(actions='modify_and_rename_file',
454
check='file_renamed_and_more_content')),
456
dict(actions='delete_file', check='file_doesnt_exist')),),
457
425
# File modified/deleted in dir
458
426
(dict(_base_actions='create_file_in_dir',
459
427
_path='dir/file', _file_id='file-id'),
471
439
def do_modify_file(self):
472
440
return [('modify', ('file-id', 'trunk content\nmore content\n'))]
474
def do_modify_and_rename_file(self):
475
return [('modify', ('file-id', 'trunk content\nmore content\n')),
476
('rename', ('file', 'new-file'))]
478
442
def check_file_has_more_content(self):
479
443
self.assertFileEqual('trunk content\nmore content\n', 'branch/file')
481
def check_file_renamed_and_more_content(self):
482
self.assertFileEqual('trunk content\nmore content\n', 'branch/new-file')
484
445
def do_delete_file(self):
485
446
return [('unversion', 'file-id')]
487
448
def check_file_doesnt_exist(self):
488
self.assertPathDoesNotExist('branch/file')
449
self.failIfExists('branch/file')
490
451
def do_create_file_in_dir(self):
491
452
return [('add', ('dir', 'dir-id', 'directory', '')),
579
540
return [('rename', ('file', 'new-file'))]
581
542
def check_file_renamed(self):
582
self.assertPathDoesNotExist('branch/file')
583
self.assertPathExists('branch/new-file')
543
self.failIfExists('branch/file')
544
self.failUnlessExists('branch/new-file')
585
546
def do_rename_file2(self):
586
547
return [('rename', ('file', 'new-file2'))]
588
549
def check_file_renamed2(self):
589
self.assertPathDoesNotExist('branch/file')
590
self.assertPathExists('branch/new-file2')
550
self.failIfExists('branch/file')
551
self.failUnlessExists('branch/new-file2')
592
553
def do_rename_dir(self):
593
554
return [('rename', ('dir', 'new-dir'))]
595
556
def check_dir_renamed(self):
596
self.assertPathDoesNotExist('branch/dir')
597
self.assertPathExists('branch/new-dir')
557
self.failIfExists('branch/dir')
558
self.failUnlessExists('branch/new-dir')
599
560
def do_rename_dir2(self):
600
561
return [('rename', ('dir', 'new-dir2'))]
602
563
def check_dir_renamed2(self):
603
self.assertPathDoesNotExist('branch/dir')
604
self.assertPathExists('branch/new-dir2')
564
self.failIfExists('branch/dir')
565
self.failUnlessExists('branch/new-dir2')
606
567
def do_delete_file(self):
607
568
return [('unversion', 'file-id')]
609
570
def check_file_doesnt_exist(self):
610
self.assertPathDoesNotExist('branch/file')
571
self.failIfExists('branch/file')
612
573
def do_delete_dir(self):
613
574
return [('unversion', 'dir-id')]
615
576
def check_dir_doesnt_exist(self):
616
self.assertPathDoesNotExist('branch/dir')
577
self.failIfExists('branch/dir')
618
579
def do_create_file_in_dir(self):
619
580
return [('add', ('dir', 'dir-id', 'directory', '')),
623
584
return [('rename', ('dir/file', 'dir/new-file'))]
625
586
def check_file_in_dir_renamed(self):
626
self.assertPathDoesNotExist('branch/dir/file')
627
self.assertPathExists('branch/dir/new-file')
587
self.failIfExists('branch/dir/file')
588
self.failUnlessExists('branch/dir/new-file')
629
590
def check_file_in_dir_doesnt_exist(self):
630
self.assertPathDoesNotExist('branch/dir/file')
591
self.failIfExists('branch/dir/file')
632
593
def _get_resolve_path_arg(self, wt, action):
633
594
tpath = self._this['path']
924
885
return [('rename', ('dir1', 'dir2/dir1'))]
926
887
def check_dir1_moved(self):
927
self.assertPathDoesNotExist('branch/dir1')
928
self.assertPathExists('branch/dir2/dir1')
888
self.failIfExists('branch/dir1')
889
self.failUnlessExists('branch/dir2/dir1')
930
891
def do_move_dir2_into_dir1(self):
931
892
return [('rename', ('dir2', 'dir1/dir2'))]
933
894
def check_dir2_moved(self):
934
self.assertPathDoesNotExist('branch/dir2')
935
self.assertPathExists('branch/dir1/dir2')
895
self.failIfExists('branch/dir2')
896
self.failUnlessExists('branch/dir1/dir2')
937
898
def do_create_dir1_4(self):
938
899
return [('add', ('dir1', 'dir1-id', 'directory', '')),
944
905
return [('rename', ('dir1', 'dir3/dir4/dir1'))]
946
907
def check_dir1_2_moved(self):
947
self.assertPathDoesNotExist('branch/dir1')
948
self.assertPathExists('branch/dir3/dir4/dir1')
949
self.assertPathExists('branch/dir3/dir4/dir1/dir2')
908
self.failIfExists('branch/dir1')
909
self.failUnlessExists('branch/dir3/dir4/dir1')
910
self.failUnlessExists('branch/dir3/dir4/dir1/dir2')
951
912
def do_move_dir3_into_dir2(self):
952
913
return [('rename', ('dir3', 'dir1/dir2/dir3'))]
954
915
def check_dir3_4_moved(self):
955
self.assertPathDoesNotExist('branch/dir3')
956
self.assertPathExists('branch/dir1/dir2/dir3')
957
self.assertPathExists('branch/dir1/dir2/dir3/dir4')
916
self.failIfExists('branch/dir3')
917
self.failUnlessExists('branch/dir1/dir2/dir3')
918
self.failUnlessExists('branch/dir1/dir2/dir3/dir4')
959
920
def _get_resolve_path_arg(self, wt, action):
960
921
# ParentLoop says: moving <conflict_path> into <path>. Cancelled move.
1066
class TestNoFinalPath(script.TestCaseWithTransportAndScript):
1068
def test_bug_805809(self):
1071
Created a standalone tree (format: 2a)
1076
$ bzr commit -m 'create file on trunk'
1077
2>Committing to: .../trunk/
1079
2>Committed revision 1.
1080
# Create a debian branch based on trunk
1082
$ bzr branch trunk -r 1 debian
1083
2>Branched 1 revision.
1090
$ bzr commit -m 'rename file to dir/file for debian'
1091
2>Committing to: .../debian/
1093
2>renamed file => dir/file
1094
2>Committed revision 2.
1095
# Create an experimental branch with a new root-id
1097
$ bzr init experimental
1098
Created a standalone tree (format: 2a)
1100
# Work around merging into empty branch not being supported
1101
# (http://pad.lv/308562)
1102
$ echo something >not-empty
1105
$ bzr commit -m 'Add some content in experimental'
1106
2>Committing to: .../experimental/
1108
2>Committed revision 1.
1109
# merge debian even without a common ancestor
1110
$ bzr merge ../debian -r0..2
1113
2>All changes applied successfully.
1114
$ bzr commit -m 'merging debian into experimental'
1115
2>Committing to: .../experimental/
1118
2>Committed revision 2.
1119
# Create an ubuntu branch with yet another root-id
1122
Created a standalone tree (format: 2a)
1124
# Work around merging into empty branch not being supported
1125
# (http://pad.lv/308562)
1126
$ echo something >not-empty-ubuntu
1128
adding not-empty-ubuntu
1129
$ bzr commit -m 'Add some content in experimental'
1130
2>Committing to: .../ubuntu/
1131
2>added not-empty-ubuntu
1132
2>Committed revision 1.
1134
$ bzr merge ../debian -r0..2
1137
2>All changes applied successfully.
1138
$ bzr commit -m 'merging debian'
1139
2>Committing to: .../ubuntu/
1142
2>Committed revision 2.
1143
# Now try to merge experimental
1144
$ bzr merge ../experimental
1146
2>Path conflict: dir / dir
1147
2>1 conflicts encountered.
1151
1027
class TestResolveActionOption(tests.TestCase):
1153
1029
def setUp(self):