71
71
def test_resolve_conflict_dir(self):
72
72
tree = self.make_branch_and_tree('.')
73
self.build_tree_contents([('hello', 'hello world4'),
74
('hello.THIS', 'hello world2'),
75
('hello.BASE', 'hello world1'),
73
self.build_tree_contents([('hello', b'hello world4'),
74
('hello.THIS', b'hello world2'),
75
('hello.BASE', b'hello world1'),
77
77
os.mkdir('hello.OTHER')
78
78
tree.add('hello', 'q')
302
302
builder.start_series()
304
304
# Create an empty trunk
305
builder.build_snapshot('start', None, [
306
('add', ('', 'root-id', 'directory', ''))])
305
builder.build_snapshot(None, [
306
('add', ('', 'root-id', 'directory', ''))],
307
308
# Add a minimal base content
308
309
base_actions = self._get_actions(self._base_actions)()
309
builder.build_snapshot('base', ['start'], base_actions)
310
builder.build_snapshot(['start'], base_actions, revision_id='base')
310
311
# Modify the base content in branch
311
312
actions_other = self._get_actions(self._other['actions'])()
312
builder.build_snapshot('other', ['base'], actions_other)
313
builder.build_snapshot(['base'], actions_other, revision_id='other')
313
314
# Modify the base content in trunk
314
315
actions_this = self._get_actions(self._this['actions'])()
315
builder.build_snapshot('this', ['base'], actions_this)
316
builder.build_snapshot(['base'], actions_this, revision_id='this')
316
317
# builder.get_branch() tip is now 'this'
318
319
builder.finish_series()
384
385
(dict(_base_actions='create_file_in_dir',
385
386
_path='dir/file', _file_id='file-id'),
386
387
('filed_modified_A_in_dir',
387
dict(actions='modify_file_A',
388
dict(actions='modify_file_A_in_dir',
388
389
check='file_in_dir_has_content_A')),
389
390
('file_modified_B',
390
dict(actions='modify_file_B',
391
dict(actions='modify_file_B_in_dir',
391
392
check='file_in_dir_has_content_B')),),
395
396
return [('add', (path, 'file-id', 'file', 'trunk content\n'))]
397
398
def do_modify_file_A(self):
398
return [('modify', ('file-id', 'trunk content\nfeature A\n'))]
399
return [('modify', ('file', 'trunk content\nfeature A\n'))]
400
401
def do_modify_file_B(self):
401
return [('modify', ('file-id', 'trunk content\nfeature B\n'))]
402
return [('modify', ('file', 'trunk content\nfeature B\n'))]
404
def do_modify_file_A_in_dir(self):
405
return [('modify', ('dir/file', 'trunk content\nfeature A\n'))]
407
def do_modify_file_B_in_dir(self):
408
return [('modify', ('dir/file', 'trunk content\nfeature B\n'))]
403
410
def check_file_has_content_A(self, path='file'):
404
411
self.assertFileEqual('trunk content\nfeature A\n',
460
467
dict(actions='modify_file_in_dir',
461
468
check='file_in_dir_has_more_content')),
462
469
('file_deleted_in_dir',
463
dict(actions='delete_file',
470
dict(actions='delete_file_in_dir',
464
471
check='file_in_dir_doesnt_exist')),),
468
475
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
470
477
def do_modify_file(self):
471
return [('modify', ('file-id', 'trunk content\nmore content\n'))]
478
return [('modify', ('file', 'trunk content\nmore content\n'))]
473
480
def do_modify_and_rename_file(self):
474
return [('modify', ('file-id', 'trunk content\nmore content\n')),
481
return [('modify', ('new-file', 'trunk content\nmore content\n')),
475
482
('rename', ('file', 'new-file'))]
477
484
def check_file_has_more_content(self):
481
488
self.assertFileEqual('trunk content\nmore content\n', 'branch/new-file')
483
490
def do_delete_file(self):
484
return [('unversion', 'file-id')]
491
return [('unversion', 'file')]
493
def do_delete_file_in_dir(self):
494
return [('unversion', 'dir/file')]
486
496
def check_file_doesnt_exist(self):
487
497
self.assertPathDoesNotExist('branch/file')
491
501
('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
493
503
def do_modify_file_in_dir(self):
494
return [('modify', ('file-id', 'trunk content\nmore content\n'))]
504
return [('modify', ('dir/file', 'trunk content\nmore content\n'))]
496
506
def check_file_in_dir_has_more_content(self):
497
507
self.assertFileEqual('trunk content\nmore content\n', 'branch/dir/file')
536
546
dict(actions='rename_file_in_dir', check='file_in_dir_renamed',
537
547
path='dir/new-file', file_id='file-id')),
539
dict(actions='delete_file', check='file_in_dir_doesnt_exist',
549
dict(actions='delete_file_in_dir', check='file_in_dir_doesnt_exist',
540
550
# PathConflicts deletion handling requires a special
541
551
# hard-coded value
542
552
path='<deleted>', file_id='file-id')),),
603
613
self.assertPathExists('branch/new-dir2')
605
615
def do_delete_file(self):
606
return [('unversion', 'file-id')]
616
return [('unversion', 'file')]
618
def do_delete_file_in_dir(self):
619
return [('unversion', 'dir/file')]
608
621
def check_file_doesnt_exist(self):
609
622
self.assertPathDoesNotExist('branch/file')
611
624
def do_delete_dir(self):
612
return [('unversion', 'dir-id')]
625
return [('unversion', 'dir')]
614
627
def check_dir_doesnt_exist(self):
615
628
self.assertPathDoesNotExist('branch/dir')
702
715
self.assertFileEqual('file b content\n', 'branch/file')
704
717
def do_replace_file_a_by_b(self):
705
return [('unversion', 'file-a-id'),
718
return [('unversion', 'file'),
706
719
('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
708
721
def do_modify_file_a(self):
709
return [('modify', ('file-a-id', 'new content\n'))]
722
return [('modify', ('file', 'new content\n'))]
711
724
def check_file_new_content(self):
712
725
self.assertFileEqual('new content\n', 'branch/file')