253
253
# Each base scenario is duplicated switching the roles of 'this' and
255
left = [l for l,r in base_scenarios]
256
right = [r for l,r in base_scenarios]
257
for (lname, ldict), (rname, rdict) in zip(left, right):
258
scenarios.extend(tests.multiply_scenarios(
259
[(lname, adapt(ldict, 'this'))],
260
[(rname, adapt(rdict, 'other'))]))
261
scenarios.extend(tests.multiply_scenarios(
255
left = [l for l, r, c in base_scenarios]
256
right = [r for l, r, c in base_scenarios]
257
common = [c for l, r, c in base_scenarios]
258
for (lname, ldict), (rname, rdict), common in zip(left, right, common):
259
a = tests.multiply_scenarios([(lname, adapt(ldict, 'this'))],
260
[(rname, adapt(rdict, 'other'))])
261
b = tests.multiply_scenarios(
262
262
[(rname, adapt(rdict, 'this'))],
263
[(lname, adapt(ldict, 'other'))]))
264
# Inject the common parameters in all scenarios
265
for name, d in scenarios:
266
d.update(common_params)
263
[(lname, adapt(ldict, 'other'))])
264
# Inject the common parameters in all scenarios
265
for name, d in a + b:
267
scenarios.extend(a + b)
334
335
def check_file_doesnt_exist(self):
335
336
self.failIfExists('branch/file')
338
def do_rename_file(self):
339
return ('new-file', 'file-id', [('rename', ('file', 'new-file'))])
341
def check_file_renamed(self):
342
self.failIfExists('branch/file')
343
self.failUnlessExists('branch/new-file')
337
345
def do_rename_dir(self):
338
346
return ('new-dir', 'dir-id', [('rename', ('dir', 'new-dir'))])
387
395
(('file_modified', dict(actions='modify_file',
388
396
check='file_has_more_content')),
389
397
('file_deleted', dict(actions='delete_file',
390
check='file_doesnt_exist'))),
398
check='file_doesnt_exist')),
399
dict(_actions_base='create_file',
400
_item_path='file', item_id='file-id',)),
392
return klass.mirror_scenarios(common, base_scenarios)
402
return klass.mirror_scenarios(base_scenarios)
394
def assertContentsConflict(self, c):
404
def assertContentsConflict(self, wt, c):
395
405
self.assertEqual(self._other_id, c.file_id)
396
406
self.assertEqual(self._other_path, c.path)
397
407
_assert_conflict = assertContentsConflict
406
416
def scenarios(klass):
407
common = dict(_actions_base='create_dir',
408
_item_path='new-dir', _item_id='dir-id',)
417
for_dirs = dict(_actions_base='create_dir',
418
_item_path='new-dir', _item_id='dir-id',)
409
419
base_scenarios = [
410
(('dir_renamed', dict(actions='rename_dir', check='dir_renamed')),
411
('dir_deleted', dict(actions='delete_dir', check='dir_doesnt_exist'))),
412
(('dir_renamed', dict(actions='rename_dir', check='dir_renamed')),
413
('dir_renamed2', dict(actions='rename_dir2', check='dir_renamed2'))),
415
return klass.mirror_scenarios(common, base_scenarios)
417
def assertPathConflict(self, c):
421
dict(actions='rename_file', check='file_renamed')),
423
dict(actions='delete_file', check='file_doesnt_exist')),
424
dict(_actions_base='create_file',
425
_item_path='new-file', _item_id='file-id',)),
427
dict(actions='rename_dir', check='dir_renamed')),
429
dict(actions='delete_dir', check='dir_doesnt_exist')),
432
dict(actions='rename_dir', check='dir_renamed')),
434
dict(actions='rename_dir2', check='dir_renamed2')),
437
return klass.mirror_scenarios(base_scenarios)
439
def do_delete_file(self):
440
sup = super(TestResolvePathConflict, self).do_delete_file()
441
# PathConflicts handle deletion differently and requires a special
443
return ('<deleted>',) + sup[1:]
445
def assertPathConflict(self, wt, c):
418
446
self.assertEqual(self._item_id, c.file_id)
419
447
self.assertEqual(self._this_path, c.path)
420
448
self.assertEqual(self._other_path, c.conflict_path)
421
449
_assert_conflict = assertPathConflict
424
class TestResolvePathConflictBefore531967(TestParametrizedResolveConflicts):
452
class TestResolvePathConflictBefore531967(TestResolvePathConflict):
425
453
"""Same as TestResolvePathConflict but a specific conflict object.
428
# FIXME: Now that bug #531697 is fixed, we need to inject a conflict object
429
# as it existed before the fix.
431
456
def assertPathConflict(self, c):
432
# bug #531967 is about file_id not being set in some cases
433
self.assertIs(None, c.file_id)
434
# Whatever this and other are saying, the same paths are used
435
self.assertEqual('<deleted>', c.path)
436
self.assertEqual(self._item_path, c.conflict_path)
457
# We create a conflict object as it was created before the fix and
458
# inject it into the working tree, the test will exercise the
459
# compatibility code.
460
old_c = conflicts.PathConflict('<deleted>', self._item_path,
462
wt.set_conflicts(conflicts.ConflictList([c]))
439
465
class TestResolveDuplicateEntry(TestResolveConflicts):