/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: Breezy landing bot
  • Author(s): Gustav Hartvigsson
  • Date: 2021-01-10 18:46:30 UTC
  • mfrom: (7526.1.1 brz-removed-api-doc)
  • mto: This revision was merged to the branch mainline in revision 7532.
  • Revision ID: breezy.the.bot@gmail.com-20210110184630-dxu0g9dqq020uiw6
Drop documentation for removed API API.

Merged from https://code.launchpad.net/~gustav-hartvigsson/brz/removed-api-doc/+merge/396033

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
 
18
17
import os
19
18
 
20
19
from .. import (
23
22
    option,
24
23
    osutils,
25
24
    tests,
 
25
    transform,
26
26
    )
 
27
from ..bzr import conflicts as bzr_conflicts
27
28
from . import (
28
29
    script,
29
30
    scenarios,
41
42
# u'\xe5' == a with circle
42
43
# '\xc3\xae' == u'\xee' == i with hat
43
44
# So these are u'path' and 'id' only with a circle and a hat. (shappo?)
44
 
example_conflicts = conflicts.ConflictList(
45
 
    [conflicts.MissingParent('Not deleting', u'p\xe5thg', b'\xc3\xaedg'),
46
 
     conflicts.ContentsConflict(u'p\xe5tha', None, b'\xc3\xaeda'),
47
 
     conflicts.TextConflict(u'p\xe5tha'),
48
 
     conflicts.PathConflict(u'p\xe5thb', u'p\xe5thc', b'\xc3\xaedb'),
49
 
     conflicts.DuplicateID('Unversioned existing file',
50
 
                           u'p\xe5thc', u'p\xe5thc2',
51
 
                           b'\xc3\xaedc', b'\xc3\xaedc'),
52
 
     conflicts.DuplicateEntry('Moved existing file to',
53
 
                              u'p\xe5thdd.moved', u'p\xe5thd',
54
 
                              b'\xc3\xaedd', None),
55
 
     conflicts.ParentLoop('Cancelled move', u'p\xe5the', u'p\xe5th2e',
56
 
                          None, b'\xc3\xaed2e'),
57
 
     conflicts.UnversionedParent('Versioned directory',
58
 
                                 u'p\xe5thf', b'\xc3\xaedf'),
59
 
     conflicts.NonDirectoryParent('Created directory',
60
 
                                  u'p\xe5thg', b'\xc3\xaedg'),
61
 
     ])
 
45
example_conflicts = [
 
46
     bzr_conflicts.MissingParent('Not deleting', u'p\xe5thg', b'\xc3\xaedg'),
 
47
     bzr_conflicts.ContentsConflict(u'p\xe5tha', None, b'\xc3\xaeda'),
 
48
     bzr_conflicts.TextConflict(u'p\xe5tha'),
 
49
     bzr_conflicts.PathConflict(u'p\xe5thb', u'p\xe5thc', b'\xc3\xaedb'),
 
50
     bzr_conflicts.DuplicateID('Unversioned existing file',
 
51
                               u'p\xe5thc', u'p\xe5thc2',
 
52
                               b'\xc3\xaedc', b'\xc3\xaedc'),
 
53
     bzr_conflicts.DuplicateEntry('Moved existing file to',
 
54
                                  u'p\xe5thdd.moved', u'p\xe5thd',
 
55
                                  b'\xc3\xaedd', None),
 
56
     bzr_conflicts.ParentLoop('Cancelled move', u'p\xe5the', u'p\xe5th2e',
 
57
                              None, b'\xc3\xaed2e'),
 
58
     bzr_conflicts.UnversionedParent('Versioned directory',
 
59
                                     u'p\xe5thf', b'\xc3\xaedf'),
 
60
     bzr_conflicts.NonDirectoryParent('Created directory',
 
61
                                      u'p\xe5thg', b'\xc3\xaedg'),
 
62
     ]
62
63
 
63
64
 
64
65
def vary_by_conflicts():
76
77
                                  ])
77
78
        os.mkdir('hello.OTHER')
78
79
        tree.add('hello', b'q')
79
 
        l = conflicts.ConflictList([conflicts.TextConflict('hello')])
 
80
        l = conflicts.ConflictList([bzr_conflicts.TextConflict('hello')])
80
81
        l.remove_files(tree)
81
82
 
82
83
    def test_select_conflicts(self):
88
89
                (not_selected, selected),
89
90
                tree_conflicts.select_conflicts(tree, paths, **kwargs))
90
91
 
91
 
        foo = conflicts.ContentsConflict('foo')
92
 
        bar = conflicts.ContentsConflict('bar')
 
92
        foo = bzr_conflicts.ContentsConflict('foo')
 
93
        bar = bzr_conflicts.ContentsConflict('bar')
93
94
        tree_conflicts = clist([foo, bar])
94
95
 
95
96
        check_select(clist([bar]), clist([foo]), ['foo'])
96
97
        check_select(clist(), tree_conflicts,
97
98
                     [''], ignore_misses=True, recurse=True)
98
99
 
99
 
        foobaz = conflicts.ContentsConflict('foo/baz')
 
100
        foobaz = bzr_conflicts.ContentsConflict('foo/baz')
100
101
        tree_conflicts = clist([foobaz, bar])
101
102
 
102
103
        check_select(clist([bar]), clist([foobaz]),
103
104
                     ['foo'], ignore_misses=True, recurse=True)
104
105
 
105
 
        qux = conflicts.PathConflict('qux', 'foo/baz')
 
106
        qux = bzr_conflicts.PathConflict('qux', 'foo/baz')
106
107
        tree_conflicts = clist([qux])
107
108
 
108
 
        check_select(clist(), tree_conflicts,
 
109
        check_select(tree_conflicts, clist(),
109
110
                     ['foo'], ignore_misses=True, recurse=True)
110
111
        check_select(tree_conflicts, clist(), ['foo'], ignore_misses=True)
111
112
 
114
115
        self.build_tree(['dir/', 'dir/hello'])
115
116
        tree.add(['dir', 'dir/hello'])
116
117
 
117
 
        dirhello = conflicts.ConflictList(
118
 
            [conflicts.TextConflict('dir/hello')])
 
118
        dirhello = [bzr_conflicts.TextConflict('dir/hello')]
119
119
        tree.set_conflicts(dirhello)
120
120
 
121
121
        conflicts.resolve(tree, ['dir'], recursive=False, ignore_misses=True)
136
136
        self.assertContainsString(repr(self.conflict),
137
137
                                  self.conflict.__class__.__name__)
138
138
 
139
 
    def test_stanza_roundtrip(self):
140
 
        p = self.conflict
141
 
        o = conflicts.Conflict.factory(**p.as_stanza().as_dict())
142
 
        self.assertEqual(o, p)
143
 
 
144
 
        self.assertIsInstance(o.path, str)
145
 
 
146
 
        if o.file_id is not None:
147
 
            self.assertIsInstance(o.file_id, bytes)
148
 
 
149
 
        conflict_path = getattr(o, 'conflict_path', None)
150
 
        if conflict_path is not None:
151
 
            self.assertIsInstance(conflict_path, str)
152
 
 
153
 
        conflict_file_id = getattr(o, 'conflict_file_id', None)
154
 
        if conflict_file_id is not None:
155
 
            self.assertIsInstance(conflict_file_id, bytes)
156
 
 
157
 
    def test_stanzification(self):
158
 
        stanza = self.conflict.as_stanza()
159
 
        if 'file_id' in stanza:
160
 
            # In Stanza form, the file_id has to be unicode.
161
 
            self.assertStartsWith(stanza['file_id'], u'\xeed')
162
 
        self.assertStartsWith(stanza['path'], u'p\xe5th')
163
 
        if 'conflict_path' in stanza:
164
 
            self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
165
 
        if 'conflict_file_id' in stanza:
166
 
            self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
167
 
 
168
139
 
169
140
class TestConflictList(tests.TestCase):
170
141
 
171
142
    def test_stanzas_roundtrip(self):
172
 
        stanzas_iter = example_conflicts.to_stanzas()
173
 
        processed = conflicts.ConflictList.from_stanzas(stanzas_iter)
 
143
        stanzas_iter = bzr_conflicts.ConflictList(example_conflicts).to_stanzas()
 
144
        processed = bzr_conflicts.ConflictList.from_stanzas(stanzas_iter)
174
145
        self.assertEqual(example_conflicts, processed)
175
146
 
176
147
    def test_stringification(self):
177
 
        for text, o in zip(example_conflicts.to_strings(), example_conflicts):
 
148
        for text, o in zip(
 
149
                bzr_conflicts.ConflictList(example_conflicts).to_strings(),
 
150
                example_conflicts):
178
151
            self.assertEqual(text, str(o))
179
152
 
180
153
 
366
339
 
367
340
class TestResolveTextConflicts(TestParametrizedResolveConflicts):
368
341
 
369
 
    _conflict_type = conflicts.TextConflict
 
342
    _conflict_type = bzr_conflicts.TextConflict
370
343
 
371
344
    # Set by the scenarios
372
345
    # path and file-id for the file involved in the conflict
437
410
 
438
411
class TestResolveContentsConflict(TestParametrizedResolveConflicts):
439
412
 
440
 
    _conflict_type = conflicts.ContentsConflict
 
413
    _conflict_type = bzr_conflicts.ContentsConflict
441
414
 
442
415
    # Set by the scenarios
443
416
    # path and file-id for the file involved in the conflict
523
496
 
524
497
class TestResolvePathConflict(TestParametrizedResolveConflicts):
525
498
 
526
 
    _conflict_type = conflicts.PathConflict
 
499
    _conflict_type = bzr_conflicts.PathConflict
527
500
 
528
501
    def do_nothing(self):
529
502
        return []
673
646
        # We create a conflict object as it was created before the fix and
674
647
        # inject it into the working tree, the test will exercise the
675
648
        # compatibility code.
676
 
        old_c = conflicts.PathConflict('<deleted>', self._item_path,
 
649
        old_c = bzr_conflicts.PathConflict('<deleted>', self._item_path,
677
650
                                       file_id=None)
678
 
        wt.set_conflicts(conflicts.ConflictList([old_c]))
 
651
        wt.set_conflicts([old_c])
679
652
 
680
653
 
681
654
class TestResolveDuplicateEntry(TestParametrizedResolveConflicts):
682
655
 
683
 
    _conflict_type = conflicts.DuplicateEntry
 
656
    _conflict_type = bzr_conflicts.DuplicateEntry
684
657
 
685
658
    scenarios = mirror_scenarios(
686
659
        [
919
892
 
920
893
class TestResolveParentLoop(TestParametrizedResolveConflicts):
921
894
 
922
 
    _conflict_type = conflicts.ParentLoop
 
895
    _conflict_type = bzr_conflicts.ParentLoop
923
896
 
924
897
    _this_args = None
925
898
    _other_args = None
1076
1049
        # This is nearly like TestResolveNonDirectoryParent but with branch and
1077
1050
        # trunk switched. As such it should certainly produce the same
1078
1051
        # conflict.
1079
 
        self.assertRaises(errors.MalformedTransform,
 
1052
        self.assertRaises(transform.MalformedTransform,
1080
1053
                          self.run_script, """
1081
1054
$ brz init trunk
1082
1055
...