/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_conflicts.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    option,
24
24
    osutils,
25
25
    tests,
26
 
    transform,
27
26
    )
28
27
from . import (
29
28
    script,
43
42
# '\xc3\xae' == u'\xee' == i with hat
44
43
# So these are u'path' and 'id' only with a circle and a hat. (shappo?)
45
44
example_conflicts = conflicts.ConflictList(
46
 
    [conflicts.MissingParent('Not deleting', u'p\xe5thg', b'\xc3\xaedg'),
47
 
     conflicts.ContentsConflict(u'p\xe5tha', None, b'\xc3\xaeda'),
 
45
    [conflicts.MissingParent('Not deleting', u'p\xe5thg', '\xc3\xaedg'),
 
46
     conflicts.ContentsConflict(u'p\xe5tha', None, '\xc3\xaeda'),
48
47
     conflicts.TextConflict(u'p\xe5tha'),
49
 
     conflicts.PathConflict(u'p\xe5thb', u'p\xe5thc', b'\xc3\xaedb'),
 
48
     conflicts.PathConflict(u'p\xe5thb', u'p\xe5thc', '\xc3\xaedb'),
50
49
     conflicts.DuplicateID('Unversioned existing file',
51
50
                           u'p\xe5thc', u'p\xe5thc2',
52
 
                           b'\xc3\xaedc', b'\xc3\xaedc'),
53
 
     conflicts.DuplicateEntry('Moved existing file to',
54
 
                              u'p\xe5thdd.moved', u'p\xe5thd',
55
 
                              b'\xc3\xaedd', None),
56
 
     conflicts.ParentLoop('Cancelled move', u'p\xe5the', u'p\xe5th2e',
57
 
                          None, b'\xc3\xaed2e'),
58
 
     conflicts.UnversionedParent('Versioned directory',
59
 
                                 u'p\xe5thf', b'\xc3\xaedf'),
60
 
     conflicts.NonDirectoryParent('Created directory',
61
 
                                  u'p\xe5thg', b'\xc3\xaedg'),
62
 
     ])
 
51
                           '\xc3\xaedc', '\xc3\xaedc'),
 
52
    conflicts.DuplicateEntry('Moved existing file to',
 
53
                             u'p\xe5thdd.moved', u'p\xe5thd',
 
54
                             '\xc3\xaedd', None),
 
55
    conflicts.ParentLoop('Cancelled move', u'p\xe5the', u'p\xe5th2e',
 
56
                         None, '\xc3\xaed2e'),
 
57
    conflicts.UnversionedParent('Versioned directory',
 
58
                                u'p\xe5thf', '\xc3\xaedf'),
 
59
    conflicts.NonDirectoryParent('Created directory',
 
60
                                 u'p\xe5thg', '\xc3\xaedg'),
 
61
])
63
62
 
64
63
 
65
64
def vary_by_conflicts():
71
70
 
72
71
    def test_resolve_conflict_dir(self):
73
72
        tree = self.make_branch_and_tree('.')
74
 
        self.build_tree_contents([('hello', b'hello world4'),
75
 
                                  ('hello.THIS', b'hello world2'),
76
 
                                  ('hello.BASE', b'hello world1'),
 
73
        self.build_tree_contents([('hello', 'hello world4'),
 
74
                                  ('hello.THIS', 'hello world2'),
 
75
                                  ('hello.BASE', 'hello world1'),
77
76
                                  ])
78
77
        os.mkdir('hello.OTHER')
79
 
        tree.add('hello', b'q')
 
78
        tree.add('hello', 'q')
80
79
        l = conflicts.ConflictList([conflicts.TextConflict('hello')])
81
80
        l.remove_files(tree)
82
81
 
97
96
        check_select(clist(), tree_conflicts,
98
97
                     [''], ignore_misses=True, recurse=True)
99
98
 
100
 
        foobaz = conflicts.ContentsConflict('foo/baz')
 
99
        foobaz  = conflicts.ContentsConflict('foo/baz')
101
100
        tree_conflicts = clist([foobaz, bar])
102
101
 
103
102
        check_select(clist([bar]), clist([foobaz]),
108
107
 
109
108
        check_select(clist(), tree_conflicts,
110
109
                     ['foo'], ignore_misses=True, recurse=True)
111
 
        check_select(tree_conflicts, clist(), ['foo'], ignore_misses=True)
 
110
        check_select (tree_conflicts, clist(), ['foo'], ignore_misses=True)
112
111
 
113
112
    def test_resolve_conflicts_recursive(self):
114
113
        tree = self.make_branch_and_tree('.')
115
114
        self.build_tree(['dir/', 'dir/hello'])
116
115
        tree.add(['dir', 'dir/hello'])
117
116
 
118
 
        dirhello = conflicts.ConflictList(
119
 
            [conflicts.TextConflict('dir/hello')])
 
117
        dirhello = conflicts.ConflictList([conflicts.TextConflict('dir/hello')])
120
118
        tree.set_conflicts(dirhello)
121
119
 
122
120
        conflicts.resolve(tree, ['dir'], recursive=False, ignore_misses=True)
131
129
    scenarios = scenarios.multiply_scenarios(vary_by_conflicts())
132
130
 
133
131
    def test_stringification(self):
134
 
        text = str(self.conflict)
 
132
        text = unicode(self.conflict)
135
133
        self.assertContainsString(text, self.conflict.path)
136
134
        self.assertContainsString(text.lower(), "conflict")
137
135
        self.assertContainsString(repr(self.conflict),
138
 
                                  self.conflict.__class__.__name__)
 
136
            self.conflict.__class__.__name__)
139
137
 
140
138
    def test_stanza_roundtrip(self):
141
139
        p = self.conflict
142
140
        o = conflicts.Conflict.factory(**p.as_stanza().as_dict())
143
141
        self.assertEqual(o, p)
144
142
 
145
 
        self.assertIsInstance(o.path, str)
 
143
        self.assertIsInstance(o.path, unicode)
146
144
 
147
145
        if o.file_id is not None:
148
 
            self.assertIsInstance(o.file_id, bytes)
 
146
            self.assertIsInstance(o.file_id, str)
149
147
 
150
148
        conflict_path = getattr(o, 'conflict_path', None)
151
149
        if conflict_path is not None:
152
 
            self.assertIsInstance(conflict_path, str)
 
150
            self.assertIsInstance(conflict_path, unicode)
153
151
 
154
152
        conflict_file_id = getattr(o, 'conflict_file_id', None)
155
153
        if conflict_file_id is not None:
156
 
            self.assertIsInstance(conflict_file_id, bytes)
 
154
            self.assertIsInstance(conflict_file_id, str)
157
155
 
158
156
    def test_stanzification(self):
159
157
        stanza = self.conflict.as_stanza()
176
174
 
177
175
    def test_stringification(self):
178
176
        for text, o in zip(example_conflicts.to_strings(), example_conflicts):
179
 
            self.assertEqual(text, str(o))
 
177
            self.assertEqual(text, unicode(o))
180
178
 
181
179
 
182
180
# FIXME: The shell-like tests should be converted to real whitebox tests... or
187
185
# FIXME: Tests missing for DuplicateID conflict type
188
186
class TestResolveConflicts(script.TestCaseWithTransportAndScript):
189
187
 
190
 
    preamble = None  # The setup script set by daughter classes
 
188
    preamble = None # The setup script set by daughter classes
191
189
 
192
190
    def setUp(self):
193
191
        super(TestResolveConflicts, self).setUp()
305
303
 
306
304
        # Create an empty trunk
307
305
        builder.build_snapshot(None, [
308
 
            ('add', (u'', b'root-id', 'directory', ''))],
309
 
            revision_id=b'start')
 
306
                ('add', ('', 'root-id', 'directory', ''))],
 
307
                revision_id='start')
310
308
        # Add a minimal base content
311
309
        base_actions = self._get_actions(self._base_actions)()
312
 
        builder.build_snapshot([b'start'], base_actions, revision_id=b'base')
 
310
        builder.build_snapshot(['start'], base_actions, revision_id='base')
313
311
        # Modify the base content in branch
314
312
        actions_other = self._get_actions(self._other['actions'])()
315
 
        builder.build_snapshot([b'base'], actions_other, revision_id=b'other')
 
313
        builder.build_snapshot(['base'], actions_other, revision_id='other')
316
314
        # Modify the base content in trunk
317
315
        actions_this = self._get_actions(self._this['actions'])()
318
 
        builder.build_snapshot([b'base'], actions_this, revision_id=b'this')
 
316
        builder.build_snapshot(['base'], actions_this, revision_id='this')
319
317
        # builder.get_branch() tip is now 'this'
320
318
 
321
319
        builder.finish_series()
330
328
    def _merge_other_into_this(self):
331
329
        b = self.builder.get_branch()
332
330
        wt = b.controldir.sprout('branch').open_workingtree()
333
 
        wt.merge_from_branch(b, b'other')
 
331
        wt.merge_from_branch(b, 'other')
334
332
        return wt
335
333
 
336
334
    def assertConflict(self, wt):
378
376
        [
379
377
            # File modified on both sides
380
378
            (dict(_base_actions='create_file',
381
 
                  _path='file', _file_id=b'file-id'),
 
379
                  _path='file', _file_id='file-id'),
382
380
             ('filed_modified_A',
383
381
              dict(actions='modify_file_A', check='file_has_content_A')),
384
382
             ('file_modified_B',
385
383
              dict(actions='modify_file_B', check='file_has_content_B')),),
386
384
            # File modified on both sides in dir
387
385
            (dict(_base_actions='create_file_in_dir',
388
 
                  _path='dir/file', _file_id=b'file-id'),
 
386
                  _path='dir/file', _file_id='file-id'),
389
387
             ('filed_modified_A_in_dir',
390
 
              dict(actions='modify_file_A_in_dir',
 
388
              dict(actions='modify_file_A',
391
389
                   check='file_in_dir_has_content_A')),
392
390
             ('file_modified_B',
393
 
              dict(actions='modify_file_B_in_dir',
 
391
              dict(actions='modify_file_B',
394
392
                   check='file_in_dir_has_content_B')),),
395
393
            ])
396
394
 
397
395
    def do_create_file(self, path='file'):
398
 
        return [('add', (path, b'file-id', 'file', b'trunk content\n'))]
 
396
        return [('add', (path, 'file-id', 'file', 'trunk content\n'))]
399
397
 
400
398
    def do_modify_file_A(self):
401
 
        return [('modify', ('file', b'trunk content\nfeature A\n'))]
 
399
        return [('modify', ('file-id', 'trunk content\nfeature A\n'))]
402
400
 
403
401
    def do_modify_file_B(self):
404
 
        return [('modify', ('file', b'trunk content\nfeature B\n'))]
405
 
 
406
 
    def do_modify_file_A_in_dir(self):
407
 
        return [('modify', ('dir/file', b'trunk content\nfeature A\n'))]
408
 
 
409
 
    def do_modify_file_B_in_dir(self):
410
 
        return [('modify', ('dir/file', b'trunk content\nfeature B\n'))]
 
402
        return [('modify', ('file-id', 'trunk content\nfeature B\n'))]
411
403
 
412
404
    def check_file_has_content_A(self, path='file'):
413
 
        self.assertFileEqual(b'trunk content\nfeature A\n',
 
405
        self.assertFileEqual('trunk content\nfeature A\n',
414
406
                             osutils.pathjoin('branch', path))
415
407
 
416
408
    def check_file_has_content_B(self, path='file'):
417
 
        self.assertFileEqual(b'trunk content\nfeature B\n',
 
409
        self.assertFileEqual('trunk content\nfeature B\n',
418
410
                             osutils.pathjoin('branch', path))
419
411
 
420
412
    def do_create_file_in_dir(self):
421
 
        return [('add', ('dir', b'dir-id', 'directory', '')),
422
 
                ] + self.do_create_file('dir/file')
 
413
        return [('add', ('dir', 'dir-id', 'directory', '')),
 
414
            ] + self.do_create_file('dir/file')
423
415
 
424
416
    def check_file_in_dir_has_content_A(self):
425
417
        self.check_file_has_content_A('dir/file')
449
441
        [
450
442
            # File modified/deleted
451
443
            (dict(_base_actions='create_file',
452
 
                  _path='file', _file_id=b'file-id'),
 
444
                  _path='file', _file_id='file-id'),
453
445
             ('file_modified',
454
446
              dict(actions='modify_file', check='file_has_more_content')),
455
447
             ('file_deleted',
456
448
              dict(actions='delete_file', check='file_doesnt_exist')),),
457
449
            # File renamed-modified/deleted
458
450
            (dict(_base_actions='create_file',
459
 
                  _path='new-file', _file_id=b'file-id'),
 
451
                  _path='new-file', _file_id='file-id'),
460
452
             ('file_renamed_and_modified',
461
453
              dict(actions='modify_and_rename_file',
462
454
                   check='file_renamed_and_more_content')),
464
456
              dict(actions='delete_file', check='file_doesnt_exist')),),
465
457
            # File modified/deleted in dir
466
458
            (dict(_base_actions='create_file_in_dir',
467
 
                  _path='dir/file', _file_id=b'file-id'),
 
459
                  _path='dir/file', _file_id='file-id'),
468
460
             ('file_modified_in_dir',
469
461
              dict(actions='modify_file_in_dir',
470
462
                   check='file_in_dir_has_more_content')),
471
463
             ('file_deleted_in_dir',
472
 
              dict(actions='delete_file_in_dir',
 
464
              dict(actions='delete_file',
473
465
                   check='file_in_dir_doesnt_exist')),),
474
466
            ])
475
467
 
476
468
    def do_create_file(self):
477
 
        return [('add', ('file', b'file-id', 'file', b'trunk content\n'))]
 
469
        return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
478
470
 
479
471
    def do_modify_file(self):
480
 
        return [('modify', ('file', b'trunk content\nmore content\n'))]
 
472
        return [('modify', ('file-id', 'trunk content\nmore content\n'))]
481
473
 
482
474
    def do_modify_and_rename_file(self):
483
 
        return [('modify', ('new-file', b'trunk content\nmore content\n')),
 
475
        return [('modify', ('file-id', 'trunk content\nmore content\n')),
484
476
                ('rename', ('file', 'new-file'))]
485
477
 
486
478
    def check_file_has_more_content(self):
487
 
        self.assertFileEqual(b'trunk content\nmore content\n', 'branch/file')
 
479
        self.assertFileEqual('trunk content\nmore content\n', 'branch/file')
488
480
 
489
481
    def check_file_renamed_and_more_content(self):
490
 
        self.assertFileEqual(
491
 
            b'trunk content\nmore content\n', 'branch/new-file')
 
482
        self.assertFileEqual('trunk content\nmore content\n', 'branch/new-file')
492
483
 
493
484
    def do_delete_file(self):
494
 
        return [('unversion', 'file')]
495
 
 
496
 
    def do_delete_file_in_dir(self):
497
 
        return [('unversion', 'dir/file')]
 
485
        return [('unversion', 'file-id')]
498
486
 
499
487
    def check_file_doesnt_exist(self):
500
488
        self.assertPathDoesNotExist('branch/file')
501
489
 
502
490
    def do_create_file_in_dir(self):
503
 
        return [('add', ('dir', b'dir-id', 'directory', '')),
504
 
                ('add', ('dir/file', b'file-id', 'file', b'trunk content\n'))]
 
491
        return [('add', ('dir', 'dir-id', 'directory', '')),
 
492
                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
505
493
 
506
494
    def do_modify_file_in_dir(self):
507
 
        return [('modify', ('dir/file', b'trunk content\nmore content\n'))]
 
495
        return [('modify', ('file-id', 'trunk content\nmore content\n'))]
508
496
 
509
497
    def check_file_in_dir_has_more_content(self):
510
 
        self.assertFileEqual(
511
 
            b'trunk content\nmore content\n', 'branch/dir/file')
 
498
        self.assertFileEqual('trunk content\nmore content\n', 'branch/dir/file')
512
499
 
513
500
    def check_file_in_dir_doesnt_exist(self):
514
501
        self.assertPathDoesNotExist('branch/dir/file')
538
525
            (dict(_base_actions='create_file'),
539
526
             ('file_renamed',
540
527
              dict(actions='rename_file', check='file_renamed',
541
 
                   path='new-file', file_id=b'file-id')),
 
528
                   path='new-file', file_id='file-id')),
542
529
             ('file_deleted',
543
530
              dict(actions='delete_file', check='file_doesnt_exist',
544
531
                   # PathConflicts deletion handling requires a special
545
532
                   # hard-coded value
546
 
                   path='<deleted>', file_id=b'file-id')),),
 
533
                   path='<deleted>', file_id='file-id')),),
547
534
            # File renamed/deleted in dir
548
535
            (dict(_base_actions='create_file_in_dir'),
549
536
             ('file_renamed_in_dir',
550
537
              dict(actions='rename_file_in_dir', check='file_in_dir_renamed',
551
 
                   path='dir/new-file', file_id=b'file-id')),
 
538
                   path='dir/new-file', file_id='file-id')),
552
539
             ('file_deleted',
553
 
              dict(actions='delete_file_in_dir', check='file_in_dir_doesnt_exist',
 
540
              dict(actions='delete_file', check='file_in_dir_doesnt_exist',
554
541
                   # PathConflicts deletion handling requires a special
555
542
                   # hard-coded value
556
 
                   path='<deleted>', file_id=b'file-id')),),
 
543
                   path='<deleted>', file_id='file-id')),),
557
544
            # File renamed/renamed differently
558
545
            (dict(_base_actions='create_file'),
559
546
             ('file_renamed',
560
547
              dict(actions='rename_file', check='file_renamed',
561
 
                   path='new-file', file_id=b'file-id')),
 
548
                   path='new-file', file_id='file-id')),
562
549
             ('file_renamed2',
563
550
              dict(actions='rename_file2', check='file_renamed2',
564
 
                   path='new-file2', file_id=b'file-id')),),
 
551
                   path='new-file2', file_id='file-id')),),
565
552
            # Dir renamed/deleted
566
553
            (dict(_base_actions='create_dir'),
567
554
             ('dir_renamed',
568
555
              dict(actions='rename_dir', check='dir_renamed',
569
 
                   path='new-dir', file_id=b'dir-id')),
 
556
                   path='new-dir', file_id='dir-id')),
570
557
             ('dir_deleted',
571
558
              dict(actions='delete_dir', check='dir_doesnt_exist',
572
559
                   # PathConflicts deletion handling requires a special
573
560
                   # hard-coded value
574
 
                   path='<deleted>', file_id=b'dir-id')),),
 
561
                   path='<deleted>', file_id='dir-id')),),
575
562
            # Dir renamed/renamed differently
576
563
            (dict(_base_actions='create_dir'),
577
564
             ('dir_renamed',
578
565
              dict(actions='rename_dir', check='dir_renamed',
579
 
                   path='new-dir', file_id=b'dir-id')),
 
566
                   path='new-dir', file_id='dir-id')),
580
567
             ('dir_renamed2',
581
568
              dict(actions='rename_dir2', check='dir_renamed2',
582
 
                   path='new-dir2', file_id=b'dir-id')),),
 
569
                   path='new-dir2', file_id='dir-id')),),
583
570
            ])
584
571
 
585
572
    def do_create_file(self):
586
 
        return [('add', ('file', b'file-id', 'file', b'trunk content\n'))]
 
573
        return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
587
574
 
588
575
    def do_create_dir(self):
589
 
        return [('add', ('dir', b'dir-id', 'directory', ''))]
 
576
        return [('add', ('dir', 'dir-id', 'directory', ''))]
590
577
 
591
578
    def do_rename_file(self):
592
579
        return [('rename', ('file', 'new-file'))]
617
604
        self.assertPathExists('branch/new-dir2')
618
605
 
619
606
    def do_delete_file(self):
620
 
        return [('unversion', 'file')]
621
 
 
622
 
    def do_delete_file_in_dir(self):
623
 
        return [('unversion', 'dir/file')]
 
607
        return [('unversion', 'file-id')]
624
608
 
625
609
    def check_file_doesnt_exist(self):
626
610
        self.assertPathDoesNotExist('branch/file')
627
611
 
628
612
    def do_delete_dir(self):
629
 
        return [('unversion', 'dir')]
 
613
        return [('unversion', 'dir-id')]
630
614
 
631
615
    def check_dir_doesnt_exist(self):
632
616
        self.assertPathDoesNotExist('branch/dir')
633
617
 
634
618
    def do_create_file_in_dir(self):
635
 
        return [('add', ('dir', b'dir-id', 'directory', '')),
636
 
                ('add', ('dir/file', b'file-id', 'file', b'trunk content\n'))]
 
619
        return [('add', ('dir', 'dir-id', 'directory', '')),
 
620
                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
637
621
 
638
622
    def do_rename_file_in_dir(self):
639
623
        return [('rename', ('dir/file', 'dir/new-file'))]
659
643
        tfile_id = self._this['file_id']
660
644
        opath = self._other['path']
661
645
        ofile_id = self._other['file_id']
662
 
        self.assertEqual(tfile_id, ofile_id)  # Sanity check
 
646
        self.assertEqual(tfile_id, ofile_id) # Sanity check
663
647
        self.assertEqual(tfile_id, c.file_id)
664
648
        self.assertEqual(tpath, c.path)
665
649
        self.assertEqual(opath, c.conflict_path)
689
673
            (dict(_base_actions='nothing'),
690
674
             ('filea_created',
691
675
              dict(actions='create_file_a', check='file_content_a',
692
 
                   path='file', file_id=b'file-a-id')),
 
676
                   path='file', file_id='file-a-id')),
693
677
             ('fileb_created',
694
678
              dict(actions='create_file_b', check='file_content_b',
695
 
                   path='file', file_id=b'file-b-id')),),
 
679
                   path='file', file_id='file-b-id')),),
696
680
            # File created with different file-ids but deleted on one side
697
681
            (dict(_base_actions='create_file_a'),
698
682
             ('filea_replaced',
699
683
              dict(actions='replace_file_a_by_b', check='file_content_b',
700
 
                   path='file', file_id=b'file-b-id')),
 
684
                   path='file', file_id='file-b-id')),
701
685
             ('filea_modified',
702
686
              dict(actions='modify_file_a', check='file_new_content',
703
 
                   path='file', file_id=b'file-a-id')),),
 
687
                   path='file', file_id='file-a-id')),),
704
688
            ])
705
689
 
706
690
    def do_nothing(self):
707
691
        return []
708
692
 
709
693
    def do_create_file_a(self):
710
 
        return [('add', ('file', b'file-a-id', 'file', b'file a content\n'))]
 
694
        return [('add', ('file', 'file-a-id', 'file', 'file a content\n'))]
711
695
 
712
696
    def check_file_content_a(self):
713
 
        self.assertFileEqual(b'file a content\n', 'branch/file')
 
697
        self.assertFileEqual('file a content\n', 'branch/file')
714
698
 
715
699
    def do_create_file_b(self):
716
 
        return [('add', ('file', b'file-b-id', 'file', b'file b content\n'))]
 
700
        return [('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
717
701
 
718
702
    def check_file_content_b(self):
719
 
        self.assertFileEqual(b'file b content\n', 'branch/file')
 
703
        self.assertFileEqual('file b content\n', 'branch/file')
720
704
 
721
705
    def do_replace_file_a_by_b(self):
722
 
        return [('unversion', 'file'),
723
 
                ('add', ('file', b'file-b-id', 'file', b'file b content\n'))]
 
706
        return [('unversion', 'file-a-id'),
 
707
                ('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
724
708
 
725
709
    def do_modify_file_a(self):
726
 
        return [('modify', ('file', b'new content\n'))]
 
710
        return [('modify', ('file-a-id', 'new content\n'))]
727
711
 
728
712
    def check_file_new_content(self):
729
 
        self.assertFileEqual(b'new content\n', 'branch/file')
 
713
        self.assertFileEqual('new content\n', 'branch/file')
730
714
 
731
715
    def _get_resolve_path_arg(self, wt, action):
732
716
        return self._this['path']
736
720
        tfile_id = self._this['file_id']
737
721
        opath = self._other['path']
738
722
        ofile_id = self._other['file_id']
739
 
        self.assertEqual(tpath, opath)  # Sanity check
 
723
        self.assertEqual(tpath, opath) # Sanity check
740
724
        self.assertEqual(tfile_id, c.file_id)
741
725
        self.assertEqual(tpath + '.moved', c.path)
742
726
        self.assertEqual(tpath, c.conflict_path)
936
920
            (dict(_base_actions='create_dir1_dir2'),
937
921
             ('dir1_into_dir2',
938
922
              dict(actions='move_dir1_into_dir2', check='dir1_moved',
939
 
                   dir_id=b'dir1-id', target_id=b'dir2-id', xfail=False)),
 
923
                   dir_id='dir1-id', target_id='dir2-id', xfail=False)),
940
924
             ('dir2_into_dir1',
941
925
              dict(actions='move_dir2_into_dir1', check='dir2_moved',
942
 
                   dir_id=b'dir2-id', target_id=b'dir1-id', xfail=False))),
 
926
                   dir_id='dir2-id', target_id='dir1-id', xfail=False))),
943
927
            # Subdirs moved into each other
944
928
            (dict(_base_actions='create_dir1_4'),
945
929
             ('dir1_into_dir4',
946
930
              dict(actions='move_dir1_into_dir4', check='dir1_2_moved',
947
 
                   dir_id=b'dir1-id', target_id=b'dir4-id', xfail=True)),
 
931
                   dir_id='dir1-id', target_id='dir4-id', xfail=True)),
948
932
             ('dir3_into_dir2',
949
933
              dict(actions='move_dir3_into_dir2', check='dir3_4_moved',
950
 
                   dir_id=b'dir3-id', target_id=b'dir2-id', xfail=True))),
 
934
                   dir_id='dir3-id', target_id='dir2-id', xfail=True))),
951
935
            ])
952
936
 
953
937
    def do_create_dir1_dir2(self):
954
 
        return [('add', ('dir1', b'dir1-id', 'directory', '')),
955
 
                ('add', ('dir2', b'dir2-id', 'directory', '')), ]
 
938
        return [('add', ('dir1', 'dir1-id', 'directory', '')),
 
939
                ('add', ('dir2', 'dir2-id', 'directory', '')),]
956
940
 
957
941
    def do_move_dir1_into_dir2(self):
958
942
        return [('rename', ('dir1', 'dir2/dir1'))]
969
953
        self.assertPathExists('branch/dir1/dir2')
970
954
 
971
955
    def do_create_dir1_4(self):
972
 
        return [('add', ('dir1', b'dir1-id', 'directory', '')),
973
 
                ('add', ('dir1/dir2', b'dir2-id', 'directory', '')),
974
 
                ('add', ('dir3', b'dir3-id', 'directory', '')),
975
 
                ('add', ('dir3/dir4', b'dir4-id', 'directory', '')), ]
 
956
        return [('add', ('dir1', 'dir1-id', 'directory', '')),
 
957
                ('add', ('dir1/dir2', 'dir2-id', 'directory', '')),
 
958
                ('add', ('dir3', 'dir3-id', 'directory', '')),
 
959
                ('add', ('dir3/dir4', 'dir4-id', 'directory', '')),]
976
960
 
977
961
    def do_move_dir1_into_dir4(self):
978
962
        return [('rename', ('dir1', 'dir3/dir4/dir1'))]
1028
1012
$ echo "Boo!" >foo
1029
1013
$ brz commit -q -m 'foo is now a file'
1030
1014
$ brz merge ../trunk
 
1015
2>+N  foo.new/bar
1031
1016
2>RK  foo => foo.new/
1032
 
2>+N  foo.new/bar
1033
1017
# FIXME: The message is misleading, foo.new *is* a directory when the message
1034
1018
# is displayed -- vila 090916
1035
1019
2>Conflict: foo.new is not a directory, but has files in it.  Created directory.
1077
1061
        # This is nearly like TestResolveNonDirectoryParent but with branch and
1078
1062
        # trunk switched. As such it should certainly produce the same
1079
1063
        # conflict.
1080
 
        self.assertRaises(transform.MalformedTransform,
 
1064
        self.assertRaises(errors.MalformedTransform,
1081
1065
                          self.run_script, """
1082
1066
$ brz init trunk
1083
1067
...
1188
1172
    def setUp(self):
1189
1173
        super(TestResolveActionOption, self).setUp()
1190
1174
        self.options = [conflicts.ResolveActionOption()]
1191
 
        self.parser = option.get_optparser(self.options)
 
1175
        self.parser = option.get_optparser(dict((o.name, o)
 
1176
                                                for o in self.options))
1192
1177
 
1193
1178
    def parse(self, args):
1194
1179
        return self.parser.parse_args(args)
1199
1184
 
1200
1185
    def test_done(self):
1201
1186
        opts, args = self.parse(['--action', 'done'])
1202
 
        self.assertEqual({'action': 'done'}, opts)
 
1187
        self.assertEqual({'action':'done'}, opts)
1203
1188
 
1204
1189
    def test_take_this(self):
1205
1190
        opts, args = self.parse(['--action', 'take-this'])