29
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
TestResolveContentConflicts,
39
tests.multiply_tests(sp_tests, content_conflict_scenarios(), result)
41
# No parametrization for the remaining tests
42
result.addTests(remaining_tests)
32
47
# TODO: Test commit with some added, and added-but-missing files
33
48
# RBC 20060124 is that not tested in test_commit.py ?
212
def content_conflict_scenarios():
213
return [('file,None', dict(_this_actions='modify_file',
214
_check_this='file_has_more_content',
215
_other_actions='delete_file',
216
_check_other='file_doesnt_exist',
218
('None,file', dict(_this_actions='delete_file',
219
_check_this='file_doesnt_exist',
220
_other_actions='modify_file',
221
_check_other='file_has_more_content',
197
226
class TestResolveContentConflicts(tests.TestCaseWithTransport):
199
# FIXME: We need to add the reverse case (delete in trunk, modify in
200
# branch) but that could wait until the resolution mechanism is implemented.
203
233
super(TestResolveContentConflicts, self).setUp()
210
240
builder.build_snapshot('base', ['start'], [
211
241
('add', ('file', 'file-id', 'file', 'trunk content\n'))])
212
242
# Modify the base content in branch
213
builder.build_snapshot('other', ['base'], [
214
('unversion', 'file-id')])
243
other_actions = self._get_actions(self._other_actions)
244
builder.build_snapshot('other', ['base'], other_actions())
215
245
# Modify the base content in trunk
216
builder.build_snapshot('this', ['base'], [
217
('modify', ('file-id', 'trunk content\nmore content\n'))])
246
this_actions = self._get_actions(self._this_actions)
247
builder.build_snapshot('this', ['base'], this_actions())
218
248
builder.finish_series()
219
249
self.builder = builder
251
def _get_actions(self, name):
252
return getattr(self, 'do_%s' % name)
254
def _get_check(self, name):
255
return getattr(self, 'check_%s' % name)
257
def do_modify_file(self):
258
return [('modify', ('file-id', 'trunk content\nmore content\n'))]
260
def check_file_has_more_content(self):
261
self.assertFileEqual('trunk content\nmore content\n', 'branch/file')
263
def do_delete_file(self):
264
return [('unversion', 'file-id')]
266
def check_file_doesnt_exist(self):
267
self.failIfExists('branch/file')
221
269
def _merge_other_into_this(self):
222
270
b = self.builder.get_branch()
223
271
wt = b.bzrdir.sprout('branch').open_workingtree()
244
292
self.assertConflict(wt, conflicts.ContentsConflict,
245
293
path='file', file_id='file-id',)
246
294
self.assertResolved(wt, 'file', 'take_this')
247
self.assertFileEqual('trunk content\nmore content\n', 'branch/file')
295
check_this = self._get_check(self._check_this)
249
298
def test_resolve_taking_other(self):
250
299
wt = self._merge_other_into_this()
251
300
self.assertConflict(wt, conflicts.ContentsConflict,
252
301
path='file', file_id='file-id',)
253
302
self.assertResolved(wt, 'file', 'take_other')
254
self.failIfExists('branch/file')
303
check_other = self._get_check(self._check_other)
257
307
class TestResolveDuplicateEntry(TestResolveConflicts):