/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: Martin
  • Date: 2018-06-30 22:18:39 UTC
  • mfrom: (7010 work)
  • mto: This revision was merged to the branch mainline in revision 7012.
  • Revision ID: gzlist@googlemail.com-20180630221839-98zi78xwcggestse
Merge trunk to fix conflict

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
                                  ('hello.BASE', b'hello world1'),
77
77
                                  ])
78
78
        os.mkdir('hello.OTHER')
79
 
        tree.add('hello', 'q')
 
79
        tree.add('hello', b'q')
80
80
        l = conflicts.ConflictList([conflicts.TextConflict('hello')])
81
81
        l.remove_files(tree)
82
82
 
144
144
        self.assertIsInstance(o.path, text_type)
145
145
 
146
146
        if o.file_id is not None:
147
 
            self.assertIsInstance(o.file_id, str)
 
147
            self.assertIsInstance(o.file_id, bytes)
148
148
 
149
149
        conflict_path = getattr(o, 'conflict_path', None)
150
150
        if conflict_path is not None:
152
152
 
153
153
        conflict_file_id = getattr(o, 'conflict_file_id', None)
154
154
        if conflict_file_id is not None:
155
 
            self.assertIsInstance(conflict_file_id, str)
 
155
            self.assertIsInstance(conflict_file_id, bytes)
156
156
 
157
157
    def test_stanzification(self):
158
158
        stanza = self.conflict.as_stanza()
329
329
    def _merge_other_into_this(self):
330
330
        b = self.builder.get_branch()
331
331
        wt = b.controldir.sprout('branch').open_workingtree()
332
 
        wt.merge_from_branch(b, 'other')
 
332
        wt.merge_from_branch(b, b'other')
333
333
        return wt
334
334
 
335
335
    def assertConflict(self, wt):
377
377
        [
378
378
            # File modified on both sides
379
379
            (dict(_base_actions='create_file',
380
 
                  _path='file', _file_id='file-id'),
 
380
                  _path='file', _file_id=b'file-id'),
381
381
             ('filed_modified_A',
382
382
              dict(actions='modify_file_A', check='file_has_content_A')),
383
383
             ('file_modified_B',
384
384
              dict(actions='modify_file_B', check='file_has_content_B')),),
385
385
            # File modified on both sides in dir
386
386
            (dict(_base_actions='create_file_in_dir',
387
 
                  _path='dir/file', _file_id='file-id'),
 
387
                  _path='dir/file', _file_id=b'file-id'),
388
388
             ('filed_modified_A_in_dir',
389
389
              dict(actions='modify_file_A_in_dir',
390
390
                   check='file_in_dir_has_content_A')),
394
394
            ])
395
395
 
396
396
    def do_create_file(self, path='file'):
397
 
        return [('add', (path, 'file-id', 'file', 'trunk content\n'))]
 
397
        return [('add', (path, b'file-id', 'file', b'trunk content\n'))]
398
398
 
399
399
    def do_modify_file_A(self):
400
 
        return [('modify', ('file', 'trunk content\nfeature A\n'))]
 
400
        return [('modify', ('file', b'trunk content\nfeature A\n'))]
401
401
 
402
402
    def do_modify_file_B(self):
403
 
        return [('modify', ('file', 'trunk content\nfeature B\n'))]
 
403
        return [('modify', ('file', b'trunk content\nfeature B\n'))]
404
404
 
405
405
    def do_modify_file_A_in_dir(self):
406
 
        return [('modify', ('dir/file', 'trunk content\nfeature A\n'))]
 
406
        return [('modify', ('dir/file', b'trunk content\nfeature A\n'))]
407
407
 
408
408
    def do_modify_file_B_in_dir(self):
409
 
        return [('modify', ('dir/file', 'trunk content\nfeature B\n'))]
 
409
        return [('modify', ('dir/file', b'trunk content\nfeature B\n'))]
410
410
 
411
411
    def check_file_has_content_A(self, path='file'):
412
 
        self.assertFileEqual('trunk content\nfeature A\n',
 
412
        self.assertFileEqual(b'trunk content\nfeature A\n',
413
413
                             osutils.pathjoin('branch', path))
414
414
 
415
415
    def check_file_has_content_B(self, path='file'):
416
 
        self.assertFileEqual('trunk content\nfeature B\n',
 
416
        self.assertFileEqual(b'trunk content\nfeature B\n',
417
417
                             osutils.pathjoin('branch', path))
418
418
 
419
419
    def do_create_file_in_dir(self):
420
 
        return [('add', ('dir', 'dir-id', 'directory', '')),
 
420
        return [('add', ('dir', b'dir-id', 'directory', '')),
421
421
            ] + self.do_create_file('dir/file')
422
422
 
423
423
    def check_file_in_dir_has_content_A(self):
448
448
        [
449
449
            # File modified/deleted
450
450
            (dict(_base_actions='create_file',
451
 
                  _path='file', _file_id='file-id'),
 
451
                  _path='file', _file_id=b'file-id'),
452
452
             ('file_modified',
453
453
              dict(actions='modify_file', check='file_has_more_content')),
454
454
             ('file_deleted',
455
455
              dict(actions='delete_file', check='file_doesnt_exist')),),
456
456
            # File renamed-modified/deleted
457
457
            (dict(_base_actions='create_file',
458
 
                  _path='new-file', _file_id='file-id'),
 
458
                  _path='new-file', _file_id=b'file-id'),
459
459
             ('file_renamed_and_modified',
460
460
              dict(actions='modify_and_rename_file',
461
461
                   check='file_renamed_and_more_content')),
463
463
              dict(actions='delete_file', check='file_doesnt_exist')),),
464
464
            # File modified/deleted in dir
465
465
            (dict(_base_actions='create_file_in_dir',
466
 
                  _path='dir/file', _file_id='file-id'),
 
466
                  _path='dir/file', _file_id=b'file-id'),
467
467
             ('file_modified_in_dir',
468
468
              dict(actions='modify_file_in_dir',
469
469
                   check='file_in_dir_has_more_content')),
473
473
            ])
474
474
 
475
475
    def do_create_file(self):
476
 
        return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
 
476
        return [('add', ('file', b'file-id', 'file', b'trunk content\n'))]
477
477
 
478
478
    def do_modify_file(self):
479
 
        return [('modify', ('file', 'trunk content\nmore content\n'))]
 
479
        return [('modify', ('file', b'trunk content\nmore content\n'))]
480
480
 
481
481
    def do_modify_and_rename_file(self):
482
 
        return [('modify', ('new-file', 'trunk content\nmore content\n')),
 
482
        return [('modify', ('new-file', b'trunk content\nmore content\n')),
483
483
                ('rename', ('file', 'new-file'))]
484
484
 
485
485
    def check_file_has_more_content(self):
486
 
        self.assertFileEqual('trunk content\nmore content\n', 'branch/file')
 
486
        self.assertFileEqual(b'trunk content\nmore content\n', 'branch/file')
487
487
 
488
488
    def check_file_renamed_and_more_content(self):
489
 
        self.assertFileEqual('trunk content\nmore content\n', 'branch/new-file')
 
489
        self.assertFileEqual(b'trunk content\nmore content\n', 'branch/new-file')
490
490
 
491
491
    def do_delete_file(self):
492
492
        return [('unversion', 'file')]
498
498
        self.assertPathDoesNotExist('branch/file')
499
499
 
500
500
    def do_create_file_in_dir(self):
501
 
        return [('add', ('dir', 'dir-id', 'directory', '')),
502
 
                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
 
501
        return [('add', ('dir', b'dir-id', 'directory', '')),
 
502
                ('add', ('dir/file', b'file-id', 'file', b'trunk content\n'))]
503
503
 
504
504
    def do_modify_file_in_dir(self):
505
 
        return [('modify', ('dir/file', 'trunk content\nmore content\n'))]
 
505
        return [('modify', ('dir/file', b'trunk content\nmore content\n'))]
506
506
 
507
507
    def check_file_in_dir_has_more_content(self):
508
 
        self.assertFileEqual('trunk content\nmore content\n', 'branch/dir/file')
 
508
        self.assertFileEqual(b'trunk content\nmore content\n', 'branch/dir/file')
509
509
 
510
510
    def check_file_in_dir_doesnt_exist(self):
511
511
        self.assertPathDoesNotExist('branch/dir/file')
535
535
            (dict(_base_actions='create_file'),
536
536
             ('file_renamed',
537
537
              dict(actions='rename_file', check='file_renamed',
538
 
                   path='new-file', file_id='file-id')),
 
538
                   path='new-file', file_id=b'file-id')),
539
539
             ('file_deleted',
540
540
              dict(actions='delete_file', check='file_doesnt_exist',
541
541
                   # PathConflicts deletion handling requires a special
542
542
                   # hard-coded value
543
 
                   path='<deleted>', file_id='file-id')),),
 
543
                   path='<deleted>', file_id=b'file-id')),),
544
544
            # File renamed/deleted in dir
545
545
            (dict(_base_actions='create_file_in_dir'),
546
546
             ('file_renamed_in_dir',
547
547
              dict(actions='rename_file_in_dir', check='file_in_dir_renamed',
548
 
                   path='dir/new-file', file_id='file-id')),
 
548
                   path='dir/new-file', file_id=b'file-id')),
549
549
             ('file_deleted',
550
550
              dict(actions='delete_file_in_dir', check='file_in_dir_doesnt_exist',
551
551
                   # PathConflicts deletion handling requires a special
552
552
                   # hard-coded value
553
 
                   path='<deleted>', file_id='file-id')),),
 
553
                   path='<deleted>', file_id=b'file-id')),),
554
554
            # File renamed/renamed differently
555
555
            (dict(_base_actions='create_file'),
556
556
             ('file_renamed',
557
557
              dict(actions='rename_file', check='file_renamed',
558
 
                   path='new-file', file_id='file-id')),
 
558
                   path='new-file', file_id=b'file-id')),
559
559
             ('file_renamed2',
560
560
              dict(actions='rename_file2', check='file_renamed2',
561
 
                   path='new-file2', file_id='file-id')),),
 
561
                   path='new-file2', file_id=b'file-id')),),
562
562
            # Dir renamed/deleted
563
563
            (dict(_base_actions='create_dir'),
564
564
             ('dir_renamed',
565
565
              dict(actions='rename_dir', check='dir_renamed',
566
 
                   path='new-dir', file_id='dir-id')),
 
566
                   path='new-dir', file_id=b'dir-id')),
567
567
             ('dir_deleted',
568
568
              dict(actions='delete_dir', check='dir_doesnt_exist',
569
569
                   # PathConflicts deletion handling requires a special
570
570
                   # hard-coded value
571
 
                   path='<deleted>', file_id='dir-id')),),
 
571
                   path='<deleted>', file_id=b'dir-id')),),
572
572
            # Dir renamed/renamed differently
573
573
            (dict(_base_actions='create_dir'),
574
574
             ('dir_renamed',
575
575
              dict(actions='rename_dir', check='dir_renamed',
576
 
                   path='new-dir', file_id='dir-id')),
 
576
                   path='new-dir', file_id=b'dir-id')),
577
577
             ('dir_renamed2',
578
578
              dict(actions='rename_dir2', check='dir_renamed2',
579
 
                   path='new-dir2', file_id='dir-id')),),
 
579
                   path='new-dir2', file_id=b'dir-id')),),
580
580
            ])
581
581
 
582
582
    def do_create_file(self):
583
 
        return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
 
583
        return [('add', ('file', b'file-id', 'file', b'trunk content\n'))]
584
584
 
585
585
    def do_create_dir(self):
586
 
        return [('add', ('dir', 'dir-id', 'directory', ''))]
 
586
        return [('add', ('dir', b'dir-id', 'directory', ''))]
587
587
 
588
588
    def do_rename_file(self):
589
589
        return [('rename', ('file', 'new-file'))]
629
629
        self.assertPathDoesNotExist('branch/dir')
630
630
 
631
631
    def do_create_file_in_dir(self):
632
 
        return [('add', ('dir', 'dir-id', 'directory', '')),
633
 
                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
 
632
        return [('add', ('dir', b'dir-id', 'directory', '')),
 
633
                ('add', ('dir/file', b'file-id', 'file', b'trunk content\n'))]
634
634
 
635
635
    def do_rename_file_in_dir(self):
636
636
        return [('rename', ('dir/file', 'dir/new-file'))]
686
686
            (dict(_base_actions='nothing'),
687
687
             ('filea_created',
688
688
              dict(actions='create_file_a', check='file_content_a',
689
 
                   path='file', file_id='file-a-id')),
 
689
                   path='file', file_id=b'file-a-id')),
690
690
             ('fileb_created',
691
691
              dict(actions='create_file_b', check='file_content_b',
692
 
                   path='file', file_id='file-b-id')),),
 
692
                   path='file', file_id=b'file-b-id')),),
693
693
            # File created with different file-ids but deleted on one side
694
694
            (dict(_base_actions='create_file_a'),
695
695
             ('filea_replaced',
696
696
              dict(actions='replace_file_a_by_b', check='file_content_b',
697
 
                   path='file', file_id='file-b-id')),
 
697
                   path='file', file_id=b'file-b-id')),
698
698
             ('filea_modified',
699
699
              dict(actions='modify_file_a', check='file_new_content',
700
 
                   path='file', file_id='file-a-id')),),
 
700
                   path='file', file_id=b'file-a-id')),),
701
701
            ])
702
702
 
703
703
    def do_nothing(self):
704
704
        return []
705
705
 
706
706
    def do_create_file_a(self):
707
 
        return [('add', ('file', 'file-a-id', 'file', 'file a content\n'))]
 
707
        return [('add', ('file', b'file-a-id', 'file', b'file a content\n'))]
708
708
 
709
709
    def check_file_content_a(self):
710
 
        self.assertFileEqual('file a content\n', 'branch/file')
 
710
        self.assertFileEqual(b'file a content\n', 'branch/file')
711
711
 
712
712
    def do_create_file_b(self):
713
 
        return [('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
 
713
        return [('add', ('file', b'file-b-id', 'file', b'file b content\n'))]
714
714
 
715
715
    def check_file_content_b(self):
716
 
        self.assertFileEqual('file b content\n', 'branch/file')
 
716
        self.assertFileEqual(b'file b content\n', 'branch/file')
717
717
 
718
718
    def do_replace_file_a_by_b(self):
719
719
        return [('unversion', 'file'),
720
 
                ('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
 
720
                ('add', ('file', b'file-b-id', 'file', b'file b content\n'))]
721
721
 
722
722
    def do_modify_file_a(self):
723
 
        return [('modify', ('file', 'new content\n'))]
 
723
        return [('modify', ('file', b'new content\n'))]
724
724
 
725
725
    def check_file_new_content(self):
726
 
        self.assertFileEqual('new content\n', 'branch/file')
 
726
        self.assertFileEqual(b'new content\n', 'branch/file')
727
727
 
728
728
    def _get_resolve_path_arg(self, wt, action):
729
729
        return self._this['path']
933
933
            (dict(_base_actions='create_dir1_dir2'),
934
934
             ('dir1_into_dir2',
935
935
              dict(actions='move_dir1_into_dir2', check='dir1_moved',
936
 
                   dir_id='dir1-id', target_id='dir2-id', xfail=False)),
 
936
                   dir_id=b'dir1-id', target_id='dir2-id', xfail=False)),
937
937
             ('dir2_into_dir1',
938
938
              dict(actions='move_dir2_into_dir1', check='dir2_moved',
939
 
                   dir_id='dir2-id', target_id='dir1-id', xfail=False))),
 
939
                   dir_id=b'dir2-id', target_id='dir1-id', xfail=False))),
940
940
            # Subdirs moved into each other
941
941
            (dict(_base_actions='create_dir1_4'),
942
942
             ('dir1_into_dir4',
943
943
              dict(actions='move_dir1_into_dir4', check='dir1_2_moved',
944
 
                   dir_id='dir1-id', target_id='dir4-id', xfail=True)),
 
944
                   dir_id=b'dir1-id', target_id='dir4-id', xfail=True)),
945
945
             ('dir3_into_dir2',
946
946
              dict(actions='move_dir3_into_dir2', check='dir3_4_moved',
947
 
                   dir_id='dir3-id', target_id='dir2-id', xfail=True))),
 
947
                   dir_id=b'dir3-id', target_id='dir2-id', xfail=True))),
948
948
            ])
949
949
 
950
950
    def do_create_dir1_dir2(self):
951
 
        return [('add', ('dir1', 'dir1-id', 'directory', '')),
952
 
                ('add', ('dir2', 'dir2-id', 'directory', '')),]
 
951
        return [('add', ('dir1', b'dir1-id', 'directory', '')),
 
952
                ('add', ('dir2', b'dir2-id', 'directory', '')),]
953
953
 
954
954
    def do_move_dir1_into_dir2(self):
955
955
        return [('rename', ('dir1', 'dir2/dir1'))]
966
966
        self.assertPathExists('branch/dir1/dir2')
967
967
 
968
968
    def do_create_dir1_4(self):
969
 
        return [('add', ('dir1', 'dir1-id', 'directory', '')),
970
 
                ('add', ('dir1/dir2', 'dir2-id', 'directory', '')),
971
 
                ('add', ('dir3', 'dir3-id', 'directory', '')),
972
 
                ('add', ('dir3/dir4', 'dir4-id', 'directory', '')),]
 
969
        return [('add', ('dir1', b'dir1-id', 'directory', '')),
 
970
                ('add', ('dir1/dir2', b'dir2-id', 'directory', '')),
 
971
                ('add', ('dir3', b'dir3-id', 'directory', '')),
 
972
                ('add', ('dir3/dir4', b'dir4-id', 'directory', '')),]
973
973
 
974
974
    def do_move_dir1_into_dir4(self):
975
975
        return [('rename', ('dir1', 'dir3/dir4/dir1'))]
994
994
        return wt.id2path(self._other['dir_id'])
995
995
 
996
996
    def assertParentLoop(self, wt, c):
997
 
        self.assertEqual(self._other['dir_id'], c.file_id)
998
 
        self.assertEqual(self._other['target_id'], c.conflict_file_id)
 
997
        self.assertEqual(self._other[b'dir_id'], c.file_id)
 
998
        self.assertEqual(self._other[b'target_id'], c.conflict_file_id)
999
999
        # The conflict paths are irrelevant (they are deterministic but not
1000
1000
        # worth checking since they don't provide the needed information
1001
1001
        # anyway)