42
42
# u'\xe5' == a with circle
43
43
# '\xc3\xae' == u'\xee' == i with hat
44
44
# So these are u'path' and 'id' only with a circle and a hat. (shappo?)
45
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'),
48
conflicts.TextConflict(u'p\xe5tha'),
49
conflicts.PathConflict(u'p\xe5thb', u'p\xe5thc', b'\xc3\xaedb'),
50
conflicts.DuplicateID('Unversioned existing file',
51
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',
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'),
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',
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'),
65
65
def vary_by_conflicts():
89
89
(not_selected, selected),
90
90
tree_conflicts.select_conflicts(tree, paths, **kwargs))
92
foo = conflicts.ContentsConflict('foo')
93
bar = conflicts.ContentsConflict('bar')
92
foo = bzr_conflicts.ContentsConflict('foo')
93
bar = bzr_conflicts.ContentsConflict('bar')
94
94
tree_conflicts = clist([foo, bar])
96
96
check_select(clist([bar]), clist([foo]), ['foo'])
97
97
check_select(clist(), tree_conflicts,
98
98
[''], ignore_misses=True, recurse=True)
100
foobaz = conflicts.ContentsConflict('foo/baz')
100
foobaz = bzr_conflicts.ContentsConflict('foo/baz')
101
101
tree_conflicts = clist([foobaz, bar])
103
103
check_select(clist([bar]), clist([foobaz]),
104
104
['foo'], ignore_misses=True, recurse=True)
106
qux = conflicts.PathConflict('qux', 'foo/baz')
106
qux = bzr_conflicts.PathConflict('qux', 'foo/baz')
107
107
tree_conflicts = clist([qux])
109
check_select(clist(), tree_conflicts,
109
check_select(tree_conflicts, clist(),
110
110
['foo'], ignore_misses=True, recurse=True)
111
111
check_select(tree_conflicts, clist(), ['foo'], ignore_misses=True)
115
115
self.build_tree(['dir/', 'dir/hello'])
116
116
tree.add(['dir', 'dir/hello'])
118
dirhello = conflicts.ConflictList(
119
[conflicts.TextConflict('dir/hello')])
118
dirhello = [bzr_conflicts.TextConflict('dir/hello')]
120
119
tree.set_conflicts(dirhello)
122
121
conflicts.resolve(tree, ['dir'], recursive=False, ignore_misses=True)
137
136
self.assertContainsString(repr(self.conflict),
138
137
self.conflict.__class__.__name__)
140
def test_stanza_roundtrip(self):
142
o = conflicts.Conflict.factory(**p.as_stanza().as_dict())
143
self.assertEqual(o, p)
145
self.assertIsInstance(o.path, str)
147
if o.file_id is not None:
148
self.assertIsInstance(o.file_id, bytes)
150
conflict_path = getattr(o, 'conflict_path', None)
151
if conflict_path is not None:
152
self.assertIsInstance(conflict_path, str)
154
conflict_file_id = getattr(o, 'conflict_file_id', None)
155
if conflict_file_id is not None:
156
self.assertIsInstance(conflict_file_id, bytes)
158
def test_stanzification(self):
159
stanza = self.conflict.as_stanza()
160
if 'file_id' in stanza:
161
# In Stanza form, the file_id has to be unicode.
162
self.assertStartsWith(stanza['file_id'], u'\xeed')
163
self.assertStartsWith(stanza['path'], u'p\xe5th')
164
if 'conflict_path' in stanza:
165
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
166
if 'conflict_file_id' in stanza:
167
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
170
140
class TestConflictList(tests.TestCase):
172
142
def test_stanzas_roundtrip(self):
173
stanzas_iter = example_conflicts.to_stanzas()
174
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)
175
145
self.assertEqual(example_conflicts, processed)
177
147
def test_stringification(self):
178
for text, o in zip(example_conflicts.to_strings(), example_conflicts):
149
bzr_conflicts.ConflictList(example_conflicts).to_strings(),
179
151
self.assertEqual(text, str(o))
674
646
# We create a conflict object as it was created before the fix and
675
647
# inject it into the working tree, the test will exercise the
676
648
# compatibility code.
677
old_c = conflicts.PathConflict('<deleted>', self._item_path,
649
old_c = bzr_conflicts.PathConflict('<deleted>', self._item_path,
679
wt.set_conflicts(conflicts.ConflictList([old_c]))
651
wt.set_conflicts([old_c])
682
654
class TestResolveDuplicateEntry(TestParametrizedResolveConflicts):
684
_conflict_type = conflicts.DuplicateEntry
656
_conflict_type = bzr_conflicts.DuplicateEntry
686
658
scenarios = mirror_scenarios(