124
120
self.assertEqual(conflicts.ConflictList([]), tree.conflicts())
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__)
123
class TestConflictStanzas(tests.TestCase):
138
125
def test_stanza_roundtrip(self):
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)
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)
156
145
def test_stanzification(self):
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))
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')
180
157
# FIXME: The shell-like tests should be converted to real whitebox tests... or
445
422
dict(actions='modify_file', check='file_has_more_content')),
447
424
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')),),
456
425
# File modified/deleted in dir
457
426
(dict(_base_actions='create_file_in_dir',
458
427
_path='dir/file', _file_id='file-id'),
470
439
def do_modify_file(self):
471
440
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'))]
477
442
def check_file_has_more_content(self):
478
443
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')
483
445
def do_delete_file(self):
484
446
return [('unversion', 'file-id')]
676
638
('fileb_created',
677
639
dict(actions='create_file_b', check='file_content_b',
678
640
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')),),
689
643
def do_nothing(self):
701
655
def check_file_content_b(self):
702
656
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')
714
658
def _get_resolve_path_arg(self, wt, action):
715
659
return self._this['path']
799
743
def test_keep_them_all(self):
800
744
self.run_script("""
801
745
$ bzr resolve dir
802
2>2 conflicts resolved, 0 remaining
746
2>2 conflict(s) resolved, 0 remaining
803
747
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
806
750
def test_adopt_child(self):
807
751
self.run_script("""
808
752
$ bzr mv -q dir/file2 file2
809
$ bzr rm -q dir --no-backup
753
$ bzr rm -q dir --force
810
754
$ bzr resolve dir
811
2>2 conflicts resolved, 0 remaining
755
2>2 conflict(s) resolved, 0 remaining
812
756
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
815
759
def test_kill_them_all(self):
816
760
self.run_script("""
817
$ bzr rm -q dir --no-backup
761
$ bzr rm -q dir --force
818
762
$ bzr resolve dir
819
2>2 conflicts resolved, 0 remaining
763
2>2 conflict(s) resolved, 0 remaining
820
764
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
863
807
def test_keep_them_all(self):
864
808
self.run_script("""
865
809
$ bzr resolve dir
866
2>2 conflicts resolved, 0 remaining
810
2>2 conflict(s) resolved, 0 remaining
867
811
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
870
814
def test_adopt_child(self):
871
815
self.run_script("""
872
816
$ bzr mv -q dir/file2 file2
873
$ bzr rm -q dir --no-backup
817
$ bzr rm -q dir --force
874
818
$ bzr resolve dir
875
2>2 conflicts resolved, 0 remaining
819
2>2 conflict(s) resolved, 0 remaining
876
820
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
879
823
def test_kill_them_all(self):
880
824
self.run_script("""
881
$ bzr rm -q dir --no-backup
825
$ bzr rm -q dir --force
882
826
$ bzr resolve dir
883
2>2 conflicts resolved, 0 remaining
827
2>2 conflict(s) resolved, 0 remaining
884
828
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
887
831
def test_resolve_taking_this(self):
888
832
self.run_script("""
889
833
$ bzr resolve --take-this dir
890
2>2 conflicts resolved, 0 remaining
834
2>2 conflict(s) resolved, 0 remaining
891
835
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1022
966
def test_take_this(self):
1023
967
self.run_script("""
1024
$ bzr rm -q foo.new --no-backup
968
$ bzr rm -q foo.new --force
1025
969
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
1026
970
# aside ? -- vila 090916
1027
971
$ bzr add -q foo
1028
972
$ bzr resolve foo.new
1029
2>1 conflict resolved, 0 remaining
973
2>1 conflict(s) resolved, 0 remaining
1030
974
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
1033
977
def test_take_other(self):
1034
978
self.run_script("""
1035
$ bzr rm -q foo --no-backup
979
$ bzr rm -q foo --force
1036
980
$ bzr mv -q foo.new foo
1037
981
$ bzr resolve foo
1038
2>1 conflict resolved, 0 remaining
982
2>1 conflict(s) resolved, 0 remaining
1039
983
$ 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.
1169
1027
class TestResolveActionOption(tests.TestCase):
1171
1029
def setUp(self):