120
124
self.assertEqual(conflicts.ConflictList([]), tree.conflicts())
123
class TestConflictStanzas(tests.TestCase):
127
class TestPerConflict(tests.TestCase):
129
scenarios = scenarios.multiply_scenarios(vary_by_conflicts())
131
def test_stringification(self):
132
text = unicode(self.conflict)
133
self.assertContainsString(text, self.conflict.path)
134
self.assertContainsString(text.lower(), "conflict")
135
self.assertContainsString(repr(self.conflict),
136
self.conflict.__class__.__name__)
125
138
def test_stanza_roundtrip(self):
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)
140
o = conflicts.Conflict.factory(**p.as_stanza().as_dict())
141
self.assertEqual(o, p)
143
self.assertIsInstance(o.path, unicode)
145
if o.file_id is not None:
146
self.assertIsInstance(o.file_id, str)
148
conflict_path = getattr(o, 'conflict_path', None)
149
if conflict_path is not None:
150
self.assertIsInstance(conflict_path, unicode)
152
conflict_file_id = getattr(o, 'conflict_file_id', None)
153
if conflict_file_id is not None:
154
self.assertIsInstance(conflict_file_id, str)
145
156
def test_stanzification(self):
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')
157
stanza = self.conflict.as_stanza()
158
if 'file_id' in stanza:
159
# In Stanza form, the file_id has to be unicode.
160
self.assertStartsWith(stanza['file_id'], u'\xeed')
161
self.assertStartsWith(stanza['path'], u'p\xe5th')
162
if 'conflict_path' in stanza:
163
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
164
if 'conflict_file_id' in stanza:
165
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
168
class TestConflictList(tests.TestCase):
170
def test_stanzas_roundtrip(self):
171
stanzas_iter = example_conflicts.to_stanzas()
172
processed = conflicts.ConflictList.from_stanzas(stanzas_iter)
173
self.assertEqual(example_conflicts, processed)
175
def test_stringification(self):
176
for text, o in zip(example_conflicts.to_strings(), example_conflicts):
177
self.assertEqual(text, unicode(o))
157
180
# FIXME: The shell-like tests should be converted to real whitebox tests... or
422
445
dict(actions='modify_file', check='file_has_more_content')),
424
447
dict(actions='delete_file', check='file_doesnt_exist')),),
448
# File renamed-modified/deleted
449
(dict(_base_actions='create_file',
450
_path='new-file', _file_id='file-id'),
451
('file_renamed_and_modified',
452
dict(actions='modify_and_rename_file',
453
check='file_renamed_and_more_content')),
455
dict(actions='delete_file', check='file_doesnt_exist')),),
425
456
# File modified/deleted in dir
426
457
(dict(_base_actions='create_file_in_dir',
427
458
_path='dir/file', _file_id='file-id'),
439
470
def do_modify_file(self):
440
471
return [('modify', ('file-id', 'trunk content\nmore content\n'))]
473
def do_modify_and_rename_file(self):
474
return [('modify', ('file-id', 'trunk content\nmore content\n')),
475
('rename', ('file', 'new-file'))]
442
477
def check_file_has_more_content(self):
443
478
self.assertFileEqual('trunk content\nmore content\n', 'branch/file')
480
def check_file_renamed_and_more_content(self):
481
self.assertFileEqual('trunk content\nmore content\n', 'branch/new-file')
445
483
def do_delete_file(self):
446
484
return [('unversion', 'file-id')]
638
676
('fileb_created',
639
677
dict(actions='create_file_b', check='file_content_b',
640
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'),
682
dict(actions='replace_file_a_by_b', check='file_content_b',
683
path='file', file_id='file-b-id')),
685
dict(actions='modify_file_a', check='file_new_content',
686
path='file', file_id='file-a-id')),),
643
689
def do_nothing(self):
655
701
def check_file_content_b(self):
656
702
self.assertFileEqual('file b content\n', 'branch/file')
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'))]
708
def do_modify_file_a(self):
709
return [('modify', ('file-a-id', 'new content\n'))]
711
def check_file_new_content(self):
712
self.assertFileEqual('new content\n', 'branch/file')
658
714
def _get_resolve_path_arg(self, wt, action):
659
715
return self._this['path']
743
799
def test_keep_them_all(self):
744
800
self.run_script("""
745
801
$ bzr resolve dir
746
2>2 conflict(s) resolved, 0 remaining
802
2>2 conflicts resolved, 0 remaining
747
803
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
750
806
def test_adopt_child(self):
751
807
self.run_script("""
752
808
$ bzr mv -q dir/file2 file2
753
$ bzr rm -q dir --force
809
$ bzr rm -q dir --no-backup
754
810
$ bzr resolve dir
755
2>2 conflict(s) resolved, 0 remaining
811
2>2 conflicts resolved, 0 remaining
756
812
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
759
815
def test_kill_them_all(self):
760
816
self.run_script("""
761
$ bzr rm -q dir --force
817
$ bzr rm -q dir --no-backup
762
818
$ bzr resolve dir
763
2>2 conflict(s) resolved, 0 remaining
819
2>2 conflicts resolved, 0 remaining
764
820
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
807
863
def test_keep_them_all(self):
808
864
self.run_script("""
809
865
$ bzr resolve dir
810
2>2 conflict(s) resolved, 0 remaining
866
2>2 conflicts resolved, 0 remaining
811
867
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
814
870
def test_adopt_child(self):
815
871
self.run_script("""
816
872
$ bzr mv -q dir/file2 file2
817
$ bzr rm -q dir --force
873
$ bzr rm -q dir --no-backup
818
874
$ bzr resolve dir
819
2>2 conflict(s) resolved, 0 remaining
875
2>2 conflicts resolved, 0 remaining
820
876
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
823
879
def test_kill_them_all(self):
824
880
self.run_script("""
825
$ bzr rm -q dir --force
881
$ bzr rm -q dir --no-backup
826
882
$ bzr resolve dir
827
2>2 conflict(s) resolved, 0 remaining
883
2>2 conflicts resolved, 0 remaining
828
884
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
831
887
def test_resolve_taking_this(self):
832
888
self.run_script("""
833
889
$ bzr resolve --take-this dir
834
2>2 conflict(s) resolved, 0 remaining
890
2>2 conflicts resolved, 0 remaining
835
891
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
966
1022
def test_take_this(self):
967
1023
self.run_script("""
968
$ bzr rm -q foo.new --force
1024
$ bzr rm -q foo.new --no-backup
969
1025
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
970
1026
# aside ? -- vila 090916
971
1027
$ bzr add -q foo
972
1028
$ bzr resolve foo.new
973
2>1 conflict(s) resolved, 0 remaining
1029
2>1 conflict resolved, 0 remaining
974
1030
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
977
1033
def test_take_other(self):
978
1034
self.run_script("""
979
$ bzr rm -q foo --force
1035
$ bzr rm -q foo --no-backup
980
1036
$ bzr mv -q foo.new foo
981
1037
$ bzr resolve foo
982
2>1 conflict(s) resolved, 0 remaining
1038
2>1 conflict resolved, 0 remaining
983
1039
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1084
class TestNoFinalPath(script.TestCaseWithTransportAndScript):
1086
def test_bug_805809(self):
1089
Created a standalone tree (format: 2a)
1094
$ bzr commit -m 'create file on trunk'
1095
2>Committing to: .../trunk/
1097
2>Committed revision 1.
1098
# Create a debian branch based on trunk
1100
$ bzr branch trunk -r 1 debian
1101
2>Branched 1 revision.
1108
$ bzr commit -m 'rename file to dir/file for debian'
1109
2>Committing to: .../debian/
1111
2>renamed file => dir/file
1112
2>Committed revision 2.
1113
# Create an experimental branch with a new root-id
1115
$ bzr init experimental
1116
Created a standalone tree (format: 2a)
1118
# Work around merging into empty branch not being supported
1119
# (http://pad.lv/308562)
1120
$ echo something >not-empty
1123
$ bzr commit -m 'Add some content in experimental'
1124
2>Committing to: .../experimental/
1126
2>Committed revision 1.
1127
# merge debian even without a common ancestor
1128
$ bzr merge ../debian -r0..2
1131
2>All changes applied successfully.
1132
$ bzr commit -m 'merging debian into experimental'
1133
2>Committing to: .../experimental/
1136
2>Committed revision 2.
1137
# Create an ubuntu branch with yet another root-id
1140
Created a standalone tree (format: 2a)
1142
# Work around merging into empty branch not being supported
1143
# (http://pad.lv/308562)
1144
$ echo something >not-empty-ubuntu
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.
1152
$ bzr merge ../debian -r0..2
1155
2>All changes applied successfully.
1156
$ bzr commit -m 'merging debian'
1157
2>Committing to: .../ubuntu/
1160
2>Committed revision 2.
1161
# Now try to merge experimental
1162
$ bzr merge ../experimental
1164
2>Path conflict: dir / dir
1165
2>1 conflicts encountered.
1027
1169
class TestResolveActionOption(tests.TestCase):
1029
1171
def setUp(self):