bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2011, 2016 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
16 |
|
17 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
18 |
from .. import ( |
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
19 |
merge3, |
20 |
tests, |
|
21 |
)
|
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
22 |
from ..errors import BinaryFile |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
23 |
from ..sixish import ( |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
24 |
BytesIO, |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
25 |
int2byte, |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
26 |
)
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
27 |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
28 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
29 |
def split_lines(t): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
30 |
return BytesIO(t).readlines() |
|
1102
by Martin Pool
- merge test refactoring from robertc |
31 |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
32 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
33 |
############################################################
|
34 |
# test case data from the gnu diffutils manual
|
|
35 |
# common base
|
|
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
36 |
TZU = split_lines(b""" The Nameless is the origin of Heaven and Earth; |
|
1102
by Martin Pool
- merge test refactoring from robertc |
37 |
The named is the mother of all things.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
38 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
39 |
Therefore let there always be non-being,
|
40 |
so we may see their subtlety,
|
|
41 |
And let there always be being,
|
|
42 |
so we may see their outcome.
|
|
43 |
The two are the same,
|
|
44 |
But after they are produced,
|
|
45 |
they have different names.
|
|
46 |
They both may be called deep and profound.
|
|
47 |
Deeper and more profound,
|
|
48 |
The door of all subtleties!
|
|
49 |
""") |
|
50 |
||
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
51 |
LAO = split_lines(b""" The Way that can be told of is not the eternal Way; |
|
1102
by Martin Pool
- merge test refactoring from robertc |
52 |
The name that can be named is not the eternal name.
|
53 |
The Nameless is the origin of Heaven and Earth;
|
|
54 |
The Named is the mother of all things.
|
|
55 |
Therefore let there always be non-being,
|
|
56 |
so we may see their subtlety,
|
|
57 |
And let there always be being,
|
|
58 |
so we may see their outcome.
|
|
59 |
The two are the same,
|
|
60 |
But after they are produced,
|
|
61 |
they have different names.
|
|
62 |
""") |
|
63 |
||
64 |
||
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
65 |
TAO = split_lines(b""" The Way that can be told of is not the eternal Way; |
|
1102
by Martin Pool
- merge test refactoring from robertc |
66 |
The name that can be named is not the eternal name.
|
67 |
The Nameless is the origin of Heaven and Earth;
|
|
68 |
The named is the mother of all things.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
69 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
70 |
Therefore let there always be non-being,
|
71 |
so we may see their subtlety,
|
|
72 |
And let there always be being,
|
|
73 |
so we may see their result.
|
|
74 |
The two are the same,
|
|
75 |
But after they are produced,
|
|
76 |
they have different names.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
77 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
78 |
-- The Way of Lao-Tzu, tr. Wing-tsit Chan
|
79 |
||
80 |
""") |
|
81 |
||
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
82 |
MERGED_RESULT = split_lines(b""" The Way that can be told of is not the eternal Way; |
|
1102
by Martin Pool
- merge test refactoring from robertc |
83 |
The name that can be named is not the eternal name.
|
84 |
The Nameless is the origin of Heaven and Earth;
|
|
85 |
The Named is the mother of all things.
|
|
86 |
Therefore let there always be non-being,
|
|
87 |
so we may see their subtlety,
|
|
88 |
And let there always be being,
|
|
89 |
so we may see their result.
|
|
90 |
The two are the same,
|
|
91 |
But after they are produced,
|
|
92 |
they have different names.
|
|
|
974.1.50
by aaron.bentley at utoronto
Merge of robertc@robertcollins.net-20050826013321-52eee1f1da679ee9 |
93 |
<<<<<<< LAO
|
94 |
=======
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
95 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
96 |
-- The Way of Lao-Tzu, tr. Wing-tsit Chan
|
97 |
||
|
974.1.50
by aaron.bentley at utoronto
Merge of robertc@robertcollins.net-20050826013321-52eee1f1da679ee9 |
98 |
>>>>>>> TAO
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
99 |
""") |
100 |
||
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
101 |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
102 |
class TestMerge3(tests.TestCase): |
|
1102
by Martin Pool
- merge test refactoring from robertc |
103 |
|
104 |
def test_no_changes(self): |
|
105 |
"""No conflicts because nothing changed""" |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
106 |
m3 = merge3.Merge3([b'aaa', b'bbb'], |
107 |
[b'aaa', b'bbb'], |
|
108 |
[b'aaa', b'bbb']) |
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
109 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
110 |
self.assertEqual(m3.find_unconflicted(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
111 |
[(0, 2)]) |
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
112 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
113 |
self.assertEqual(list(m3.find_sync_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
114 |
[(0, 2, |
115 |
0, 2, |
|
116 |
0, 2), |
|
117 |
(2, 2, 2, 2, 2, 2)]) |
|
|
825
by Martin Pool
- Merge3.find_sync_regions always returns a zero-length sentinal at the end to |
118 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
119 |
self.assertEqual(list(m3.merge_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
120 |
[('unchanged', 0, 2)]) |
|
825
by Martin Pool
- Merge3.find_sync_regions always returns a zero-length sentinal at the end to |
121 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
122 |
self.assertEqual(list(m3.merge_groups()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
123 |
[('unchanged', [b'aaa', b'bbb'])]) |
|
827
by Martin Pool
- new Merge3.merge_groups feeds back the merged lines |
124 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
125 |
def test_front_insert(self): |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
126 |
m3 = merge3.Merge3([b'zz'], |
127 |
[b'aaa', b'bbb', b'zz'], |
|
128 |
[b'zz']) |
|
|
825
by Martin Pool
- Merge3.find_sync_regions always returns a zero-length sentinal at the end to |
129 |
|
130 |
# todo: should use a sentinal at end as from get_matching_blocks
|
|
131 |
# to match without zz
|
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
132 |
self.assertEqual(list(m3.find_sync_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
133 |
[(0, 1, 2, 3, 0, 1), |
134 |
(1, 1, 3, 3, 1, 1), ]) |
|
|
825
by Martin Pool
- Merge3.find_sync_regions always returns a zero-length sentinal at the end to |
135 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
136 |
self.assertEqual(list(m3.merge_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
137 |
[('a', 0, 2), |
138 |
('unchanged', 0, 1)]) |
|
|
827
by Martin Pool
- new Merge3.merge_groups feeds back the merged lines |
139 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
140 |
self.assertEqual(list(m3.merge_groups()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
141 |
[('a', [b'aaa', b'bbb']), |
142 |
('unchanged', [b'zz'])]) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
143 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
144 |
def test_null_insert(self): |
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
145 |
m3 = merge3.Merge3([], |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
146 |
[b'aaa', b'bbb'], |
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
147 |
[])
|
|
825
by Martin Pool
- Merge3.find_sync_regions always returns a zero-length sentinal at the end to |
148 |
# todo: should use a sentinal at end as from get_matching_blocks
|
149 |
# to match without zz
|
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
150 |
self.assertEqual(list(m3.find_sync_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
151 |
[(0, 0, 2, 2, 0, 0)]) |
|
825
by Martin Pool
- Merge3.find_sync_regions always returns a zero-length sentinal at the end to |
152 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
153 |
self.assertEqual(list(m3.merge_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
154 |
[('a', 0, 2)]) |
|
828
by Martin Pool
- code to represent merges in regular text conflict form |
155 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
156 |
self.assertEqual(list(m3.merge_lines()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
157 |
[b'aaa', b'bbb']) |
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
158 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
159 |
def test_no_conflicts(self): |
160 |
"""No conflicts because only one side changed""" |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
161 |
m3 = merge3.Merge3([b'aaa', b'bbb'], |
162 |
[b'aaa', b'111', b'bbb'], |
|
163 |
[b'aaa', b'bbb']) |
|
|
822
by Martin Pool
- Renamed merge3 test suite for easier access. |
164 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
165 |
self.assertEqual(m3.find_unconflicted(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
166 |
[(0, 1), (1, 2)]) |
|
822
by Martin Pool
- Renamed merge3 test suite for easier access. |
167 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
168 |
self.assertEqual(list(m3.find_sync_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
169 |
[(0, 1, 0, 1, 0, 1), |
170 |
(1, 2, 2, 3, 1, 2), |
|
171 |
(2, 2, 3, 3, 2, 2), ]) |
|
|
825
by Martin Pool
- Merge3.find_sync_regions always returns a zero-length sentinal at the end to |
172 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
173 |
self.assertEqual(list(m3.merge_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
174 |
[('unchanged', 0, 1), |
175 |
('a', 1, 2), |
|
176 |
('unchanged', 1, 2), ]) |
|
|
826
by Martin Pool
- Actually merge unsynchronized regions. Woot! |
177 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
178 |
def test_append_a(self): |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
179 |
m3 = merge3.Merge3([b'aaa\n', b'bbb\n'], |
180 |
[b'aaa\n', b'bbb\n', b'222\n'], |
|
181 |
[b'aaa\n', b'bbb\n']) |
|
|
836
by Martin Pool
- more merge tests from john |
182 |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
183 |
self.assertEqual(b''.join(m3.merge_lines()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
184 |
b'aaa\nbbb\n222\n') |
|
836
by Martin Pool
- more merge tests from john |
185 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
186 |
def test_append_b(self): |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
187 |
m3 = merge3.Merge3([b'aaa\n', b'bbb\n'], |
188 |
[b'aaa\n', b'bbb\n'], |
|
189 |
[b'aaa\n', b'bbb\n', b'222\n']) |
|
|
836
by Martin Pool
- more merge tests from john |
190 |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
191 |
self.assertEqual(b''.join(m3.merge_lines()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
192 |
b'aaa\nbbb\n222\n') |
|
836
by Martin Pool
- more merge tests from john |
193 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
194 |
def test_append_agreement(self): |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
195 |
m3 = merge3.Merge3([b'aaa\n', b'bbb\n'], |
196 |
[b'aaa\n', b'bbb\n', b'222\n'], |
|
197 |
[b'aaa\n', b'bbb\n', b'222\n']) |
|
|
836
by Martin Pool
- more merge tests from john |
198 |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
199 |
self.assertEqual(b''.join(m3.merge_lines()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
200 |
b'aaa\nbbb\n222\n') |
|
836
by Martin Pool
- more merge tests from john |
201 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
202 |
def test_append_clash(self): |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
203 |
m3 = merge3.Merge3([b'aaa\n', b'bbb\n'], |
204 |
[b'aaa\n', b'bbb\n', b'222\n'], |
|
205 |
[b'aaa\n', b'bbb\n', b'333\n']) |
|
|
836
by Martin Pool
- more merge tests from john |
206 |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
207 |
ml = m3.merge_lines(name_a=b'a', |
208 |
name_b=b'b', |
|
209 |
start_marker=b'<<', |
|
210 |
mid_marker=b'--', |
|
211 |
end_marker=b'>>') |
|
212 |
self.assertEqual(b''.join(ml), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
213 |
b'''\ |
|
836
by Martin Pool
- more merge tests from john |
214 |
aaa
|
215 |
bbb
|
|
216 |
<< a
|
|
217 |
222
|
|
218 |
--
|
|
219 |
333
|
|
220 |
>> b
|
|
221 |
''') |
|
222 |
||
|
1102
by Martin Pool
- merge test refactoring from robertc |
223 |
def test_insert_agreement(self): |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
224 |
m3 = merge3.Merge3([b'aaa\n', b'bbb\n'], |
225 |
[b'aaa\n', b'222\n', b'bbb\n'], |
|
226 |
[b'aaa\n', b'222\n', b'bbb\n']) |
|
|
830
by Martin Pool
- handle chunks which differ from the base but agree |
227 |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
228 |
ml = m3.merge_lines(name_a=b'a', |
229 |
name_b=b'b', |
|
230 |
start_marker=b'<<', |
|
231 |
mid_marker=b'--', |
|
232 |
end_marker=b'>>') |
|
233 |
self.assertEqual(b''.join(ml), b'aaa\n222\nbbb\n') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
234 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
235 |
def test_insert_clash(self): |
236 |
"""Both try to insert lines in the same place.""" |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
237 |
m3 = merge3.Merge3([b'aaa\n', b'bbb\n'], |
238 |
[b'aaa\n', b'111\n', b'bbb\n'], |
|
239 |
[b'aaa\n', b'222\n', b'bbb\n']) |
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
240 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
241 |
self.assertEqual(m3.find_unconflicted(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
242 |
[(0, 1), (1, 2)]) |
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
243 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
244 |
self.assertEqual(list(m3.find_sync_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
245 |
[(0, 1, 0, 1, 0, 1), |
246 |
(1, 2, 2, 3, 2, 3), |
|
247 |
(2, 2, 3, 3, 3, 3), ]) |
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
248 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
249 |
self.assertEqual(list(m3.merge_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
250 |
[('unchanged', 0, 1), |
251 |
('conflict', 1, 1, 1, 2, 1, 2), |
|
252 |
('unchanged', 1, 2)]) |
|
|
826
by Martin Pool
- Actually merge unsynchronized regions. Woot! |
253 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
254 |
self.assertEqual(list(m3.merge_groups()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
255 |
[('unchanged', [b'aaa\n']), |
256 |
('conflict', [], [b'111\n'], [b'222\n']), |
|
257 |
('unchanged', [b'bbb\n']), |
|
258 |
])
|
|
|
827
by Martin Pool
- new Merge3.merge_groups feeds back the merged lines |
259 |
|
|
6973.11.5
by Jelmer Vernooij
Update python3.passing. |
260 |
ml = m3.merge_lines(name_a=b'a', |
261 |
name_b=b'b', |
|
262 |
start_marker=b'<<', |
|
263 |
mid_marker=b'--', |
|
264 |
end_marker=b'>>') |
|
265 |
self.assertEqual(b''.join(ml), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
266 |
b'''aaa |
|
829
by Martin Pool
- More merge3 cvs-form stuff |
267 |
<< a
|
268 |
111
|
|
269 |
--
|
|
270 |
222
|
|
271 |
>> b
|
|
272 |
bbb
|
|
273 |
''') |
|
|
828
by Martin Pool
- code to represent merges in regular text conflict form |
274 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
275 |
def test_replace_clash(self): |
276 |
"""Both try to insert lines in the same place.""" |
|
|
6973.11.5
by Jelmer Vernooij
Update python3.passing. |
277 |
m3 = merge3.Merge3([b'aaa', b'000', b'bbb'], |
278 |
[b'aaa', b'111', b'bbb'], |
|
279 |
[b'aaa', b'222', b'bbb']) |
|
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
280 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
281 |
self.assertEqual(m3.find_unconflicted(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
282 |
[(0, 1), (2, 3)]) |
|
821
by Martin Pool
- start code for built-in diff3-style resolve |
283 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
284 |
self.assertEqual(list(m3.find_sync_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
285 |
[(0, 1, 0, 1, 0, 1), |
286 |
(2, 3, 2, 3, 2, 3), |
|
287 |
(3, 3, 3, 3, 3, 3), ]) |
|
|
822
by Martin Pool
- Renamed merge3 test suite for easier access. |
288 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
289 |
def test_replace_multi(self): |
290 |
"""Replacement with regions of different size.""" |
|
|
6973.11.5
by Jelmer Vernooij
Update python3.passing. |
291 |
m3 = merge3.Merge3([b'aaa', b'000', b'000', b'bbb'], |
292 |
[b'aaa', b'111', b'111', b'111', b'bbb'], |
|
293 |
[b'aaa', b'222', b'222', b'222', b'222', b'bbb']) |
|
|
822
by Martin Pool
- Renamed merge3 test suite for easier access. |
294 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
295 |
self.assertEqual(m3.find_unconflicted(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
296 |
[(0, 1), (3, 4)]) |
|
822
by Martin Pool
- Renamed merge3 test suite for easier access. |
297 |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
298 |
self.assertEqual(list(m3.find_sync_regions()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
299 |
[(0, 1, 0, 1, 0, 1), |
300 |
(3, 4, 4, 5, 5, 6), |
|
301 |
(4, 4, 5, 5, 6, 6), ]) |
|
|
822
by Martin Pool
- Renamed merge3 test suite for easier access. |
302 |
|
|
1102
by Martin Pool
- merge test refactoring from robertc |
303 |
def test_merge_poem(self): |
304 |
"""Test case from diff3 manual""" |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
305 |
m3 = merge3.Merge3(TZU, LAO, TAO) |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
306 |
ml = list(m3.merge_lines(b'LAO', b'TAO')) |
|
831
by Martin Pool
- add merge3 test case from Lao-Tzu |
307 |
self.log('merge result:') |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
308 |
self.log(b''.join(ml)) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
309 |
self.assertEqual(ml, MERGED_RESULT) |
|
1185.24.1
by Aaron Bentley
Got reprocessing working |
310 |
|
|
1711.2.25
by John Arbash Meinel
Update the merge3 tests, so that they test more realistic data on 'minimal_conflicts' |
311 |
def test_minimal_conflicts_common(self): |
|
1185.24.1
by Aaron Bentley
Got reprocessing working |
312 |
"""Reprocessing""" |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
313 |
base_text = (b"a\n" * 20).splitlines(True) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
314 |
this_text = (b"a\n" * 10 + b"b\n" * 10).splitlines(True) |
315 |
other_text = (b"a\n" * 10 + b"c\n" + b"b\n" * |
|
316 |
8 + b"c\n").splitlines(True) |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
317 |
m3 = merge3.Merge3(base_text, other_text, this_text) |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
318 |
m_lines = m3.merge_lines(b'OTHER', b'THIS', reprocess=True) |
319 |
merged_text = b"".join(list(m_lines)) |
|
320 |
optimal_text = (b"a\n" * 10 + b"<<<<<<< OTHER\nc\n" |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
321 |
+ 8 * b"b\n" + b"c\n=======\n" |
322 |
+ 10 * b"b\n" + b">>>>>>> THIS\n") |
|
|
1711.2.25
by John Arbash Meinel
Update the merge3 tests, so that they test more realistic data on 'minimal_conflicts' |
323 |
self.assertEqualDiff(optimal_text, merged_text) |
324 |
||
325 |
def test_minimal_conflicts_unique(self): |
|
326 |
def add_newline(s): |
|
327 |
"""Add a newline to each entry in the string""" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
328 |
return [(int2byte(x) + b'\n') for x in bytearray(s)] |
|
1711.2.25
by John Arbash Meinel
Update the merge3 tests, so that they test more realistic data on 'minimal_conflicts' |
329 |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
330 |
base_text = add_newline(b"abcdefghijklm") |
331 |
this_text = add_newline(b"abcdefghijklmNOPQRSTUVWXYZ") |
|
332 |
other_text = add_newline(b"abcdefghijklm1OPQRSTUVWXY2") |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
333 |
m3 = merge3.Merge3(base_text, other_text, this_text) |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
334 |
m_lines = m3.merge_lines(b'OTHER', b'THIS', reprocess=True) |
335 |
merged_text = b"".join(list(m_lines)) |
|
336 |
optimal_text = b''.join(add_newline(b"abcdefghijklm") |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
337 |
+ [b"<<<<<<< OTHER\n1\n=======\nN\n>>>>>>> THIS\n"] |
338 |
+ add_newline(b'OPQRSTUVWXY') |
|
339 |
+ [b"<<<<<<< OTHER\n2\n=======\nZ\n>>>>>>> THIS\n"] |
|
340 |
)
|
|
|
1711.2.25
by John Arbash Meinel
Update the merge3 tests, so that they test more realistic data on 'minimal_conflicts' |
341 |
self.assertEqualDiff(optimal_text, merged_text) |
342 |
||
343 |
def test_minimal_conflicts_nonunique(self): |
|
344 |
def add_newline(s): |
|
345 |
"""Add a newline to each entry in the string""" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
346 |
return [(int2byte(x) + b'\n') for x in bytearray(s)] |
|
1711.2.25
by John Arbash Meinel
Update the merge3 tests, so that they test more realistic data on 'minimal_conflicts' |
347 |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
348 |
base_text = add_newline(b"abacddefgghij") |
349 |
this_text = add_newline(b"abacddefgghijkalmontfprz") |
|
350 |
other_text = add_newline(b"abacddefgghijknlmontfprd") |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
351 |
m3 = merge3.Merge3(base_text, other_text, this_text) |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
352 |
m_lines = m3.merge_lines(b'OTHER', b'THIS', reprocess=True) |
353 |
merged_text = b"".join(list(m_lines)) |
|
354 |
optimal_text = b''.join(add_newline(b"abacddefgghijk") |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
355 |
+ [b"<<<<<<< OTHER\nn\n=======\na\n>>>>>>> THIS\n"] |
356 |
+ add_newline(b'lmontfpr') |
|
357 |
+ [b"<<<<<<< OTHER\nd\n=======\nz\n>>>>>>> THIS\n"] |
|
358 |
)
|
|
|
1711.2.25
by John Arbash Meinel
Update the merge3 tests, so that they test more realistic data on 'minimal_conflicts' |
359 |
self.assertEqualDiff(optimal_text, merged_text) |
|
1185.24.1
by Aaron Bentley
Got reprocessing working |
360 |
|
361 |
def test_reprocess_and_base(self): |
|
362 |
"""Reprocessing and showing base breaks correctly""" |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
363 |
base_text = (b"a\n" * 20).splitlines(True) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
364 |
this_text = (b"a\n" * 10 + b"b\n" * 10).splitlines(True) |
365 |
other_text = (b"a\n" * 10 + b"c\n" + b"b\n" * |
|
366 |
8 + b"c\n").splitlines(True) |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
367 |
m3 = merge3.Merge3(base_text, other_text, this_text) |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
368 |
m_lines = m3.merge_lines(b'OTHER', b'THIS', reprocess=True, |
369 |
base_marker=b'|||||||') |
|
370 |
self.assertRaises(merge3.CantReprocessAndShowBase, list, m_lines) |
|
|
1558.15.6
by Aaron Bentley
Added more tests |
371 |
|
372 |
def test_binary(self): |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
373 |
self.assertRaises(BinaryFile, merge3.Merge3, [b'\x00'], [b'a'], [b'b']) |
|
1551.10.38
by Aaron Bentley
merge3 auto-detects line endings for conflict markers |
374 |
|
375 |
def test_dos_text(self): |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
376 |
base_text = b'a\r\n' |
377 |
this_text = b'b\r\n' |
|
378 |
other_text = b'c\r\n' |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
379 |
m3 = merge3.Merge3(base_text.splitlines(True), |
380 |
other_text.splitlines(True), |
|
381 |
this_text.splitlines(True)) |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
382 |
m_lines = m3.merge_lines(b'OTHER', b'THIS') |
383 |
self.assertEqual(b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
384 |
b'>>>>>>> THIS\r\n'.splitlines(True), list(m_lines)) |
|
1551.10.38
by Aaron Bentley
merge3 auto-detects line endings for conflict markers |
385 |
|
386 |
def test_mac_text(self): |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
387 |
base_text = b'a\r' |
388 |
this_text = b'b\r' |
|
389 |
other_text = b'c\r' |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
390 |
m3 = merge3.Merge3(base_text.splitlines(True), |
391 |
other_text.splitlines(True), |
|
392 |
this_text.splitlines(True)) |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
393 |
m_lines = m3.merge_lines(b'OTHER', b'THIS') |
394 |
self.assertEqual(b'<<<<<<< OTHER\rc\r=======\rb\r' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
395 |
b'>>>>>>> THIS\r'.splitlines(True), list(m_lines)) |
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
396 |
|
397 |
def test_merge3_cherrypick(self): |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
398 |
base_text = b"a\nb\n" |
399 |
this_text = b"a\n" |
|
400 |
other_text = b"a\nb\nc\n" |
|
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
401 |
# When cherrypicking, lines in base are not part of the conflict
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
402 |
m3 = merge3.Merge3(base_text.splitlines(True), |
403 |
this_text.splitlines(True), |
|
404 |
other_text.splitlines(True), is_cherrypick=True) |
|
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
405 |
m_lines = m3.merge_lines() |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
406 |
self.assertEqualDiff(b'a\n<<<<<<<\n=======\nc\n>>>>>>>\n', |
407 |
b''.join(m_lines)) |
|
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
408 |
|
409 |
# This is not symmetric
|
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
410 |
m3 = merge3.Merge3(base_text.splitlines(True), |
411 |
other_text.splitlines(True), |
|
412 |
this_text.splitlines(True), is_cherrypick=True) |
|
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
413 |
m_lines = m3.merge_lines() |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
414 |
self.assertEqualDiff(b'a\n<<<<<<<\nb\nc\n=======\n>>>>>>>\n', |
415 |
b''.join(m_lines)) |
|
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
416 |
|
417 |
def test_merge3_cherrypick_w_mixed(self): |
|
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
418 |
base_text = b'a\nb\nc\nd\ne\n' |
419 |
this_text = b'a\nb\nq\n' |
|
420 |
other_text = b'a\nb\nc\nd\nf\ne\ng\n' |
|
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
421 |
# When cherrypicking, lines in base are not part of the conflict
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
422 |
m3 = merge3.Merge3(base_text.splitlines(True), |
423 |
this_text.splitlines(True), |
|
424 |
other_text.splitlines(True), is_cherrypick=True) |
|
|
3249.3.1
by John Arbash Meinel
Implement cherrypick support for Merge3 |
425 |
m_lines = m3.merge_lines() |
|
7029.4.1
by Jelmer Vernooij
Fix a bunch of merge tests. |
426 |
self.assertEqualDiff(b'a\n' |
427 |
b'b\n' |
|
428 |
b'<<<<<<<\n' |
|
429 |
b'q\n' |
|
430 |
b'=======\n' |
|
431 |
b'f\n' |
|
432 |
b'>>>>>>>\n' |
|
433 |
b'<<<<<<<\n' |
|
434 |
b'=======\n' |
|
435 |
b'g\n' |
|
436 |
b'>>>>>>>\n', |
|
437 |
b''.join(m_lines)) |
|
|
5158.5.3
by Andrew Bennetts
Add a test for the allow_objects param of Merge3. |
438 |
|
439 |
def test_allow_objects(self): |
|
440 |
"""Objects other than strs may be used with Merge3 when |
|
441 |
allow_objects=True.
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
442 |
|
|
5158.5.3
by Andrew Bennetts
Add a test for the allow_objects param of Merge3. |
443 |
merge_groups and merge_regions work with non-str input. Methods that
|
444 |
return lines like merge_lines fail.
|
|
445 |
"""
|
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
446 |
base = [(x, x) for x in 'abcde'] |
447 |
a = [(x, x) for x in 'abcdef'] |
|
448 |
b = [(x, x) for x in 'Zabcde'] |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
449 |
m3 = merge3.Merge3(base, a, b, allow_objects=True) |
|
5158.5.3
by Andrew Bennetts
Add a test for the allow_objects param of Merge3. |
450 |
self.assertEqual( |
451 |
[('b', 0, 1), |
|
452 |
('unchanged', 0, 5), |
|
453 |
('a', 5, 6)], |
|
454 |
list(m3.merge_regions())) |
|
455 |
self.assertEqual( |
|
456 |
[('b', [('Z', 'Z')]), |
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
457 |
('unchanged', [(x, x) for x in 'abcde']), |
|
5158.5.3
by Andrew Bennetts
Add a test for the allow_objects param of Merge3. |
458 |
('a', [('f', 'f')])], |
459 |
list(m3.merge_groups())) |