Show More
@@ -272,7 +272,7 b' def debugbuilddag(' | |||
|
272 | 272 | x[fn].data() for x in (pa, p1, p2) |
|
273 | 273 | ] |
|
274 | 274 | m3 = simplemerge.Merge3Text(base, local, other) |
|
275 | ml = [l.strip() for l in m3.merge_lines()] | |
|
275 | ml = [l.strip() for l in m3.merge_lines()[0]] | |
|
276 | 276 | ml.append(b"") |
|
277 | 277 | elif at > 0: |
|
278 | 278 | ml = p1[fn].data().split(b"\n") |
@@ -99,7 +99,7 b' class Merge3Text(object):' | |||
|
99 | 99 | minimize=False, |
|
100 | 100 | ): |
|
101 | 101 | """Return merge in cvs-like form.""" |
|
102 |
|
|
|
102 | conflicts = False | |
|
103 | 103 | newline = b'\n' |
|
104 | 104 | if len(self.a) > 0: |
|
105 | 105 | if self.a[0].endswith(b'\r\n'): |
@@ -115,27 +115,25 b' class Merge3Text(object):' | |||
|
115 | 115 | merge_groups = self.merge_groups() |
|
116 | 116 | if minimize: |
|
117 | 117 | merge_groups = self.minimize(merge_groups) |
|
118 | for what, lines in merge_groups: | |
|
118 | lines = [] | |
|
119 | for what, group_lines in merge_groups: | |
|
119 | 120 | if what == b'conflict': |
|
120 | base_lines, a_lines, b_lines = lines | |
|
121 |
|
|
|
121 | base_lines, a_lines, b_lines = group_lines | |
|
122 | conflicts = True | |
|
122 | 123 | if start_marker is not None: |
|
123 |
|
|
|
124 |
|
|
|
125 | yield line | |
|
124 | lines.append(start_marker + newline) | |
|
125 | lines.extend(a_lines) | |
|
126 | 126 | if base_marker is not None: |
|
127 |
|
|
|
128 |
|
|
|
129 | yield line | |
|
127 | lines.append(base_marker + newline) | |
|
128 | lines.extend(base_lines) | |
|
130 | 129 | if mid_marker is not None: |
|
131 |
|
|
|
132 |
|
|
|
133 | yield line | |
|
130 | lines.append(mid_marker + newline) | |
|
131 | lines.extend(b_lines) | |
|
134 | 132 | if end_marker is not None: |
|
135 |
|
|
|
133 | lines.append(end_marker + newline) | |
|
136 | 134 | else: |
|
137 | for line in lines: | |
|
138 | yield line | |
|
135 | lines.extend(group_lines) | |
|
136 | return lines, conflicts | |
|
139 | 137 | |
|
140 | 138 | def merge_groups(self): |
|
141 | 139 | """Yield sequence of line groups. Each one is a tuple: |
@@ -510,10 +508,9 b' def simplemerge(ui, localctx, basectx, o' | |||
|
510 | 508 | extrakwargs['base_marker'] = b'|||||||' |
|
511 | 509 | extrakwargs['name_base'] = name_base |
|
512 | 510 | extrakwargs['minimize'] = False |
|
513 |
lines = lis |
|
|
514 |
|
|
|
511 | lines, conflicts = m3.merge_lines( | |
|
512 | name_a=name_a, name_b=name_b, **extrakwargs | |
|
515 | 513 | ) |
|
516 | conflicts = m3.conflicts | |
|
517 | 514 | |
|
518 | 515 | mergedtext = b''.join(lines) |
|
519 | 516 | if opts.get('print'): |
@@ -179,7 +179,7 b' class TestMerge3(TestCase):' | |||
|
179 | 179 | |
|
180 | 180 | self.assertEqual(list(m3.merge_regions()), [(b'a', 0, 2)]) |
|
181 | 181 | |
|
182 |
self.assertEqual( |
|
|
182 | self.assertEqual(m3.merge_lines(), ([b'aaa', b'bbb'], False)) | |
|
183 | 183 | |
|
184 | 184 | def test_no_conflicts(self): |
|
185 | 185 | """No conflicts because only one side changed""" |
@@ -204,7 +204,7 b' class TestMerge3(TestCase):' | |||
|
204 | 204 | [b'aaa\n', b'bbb\n'], |
|
205 | 205 | ) |
|
206 | 206 | |
|
207 | self.assertEqual(b''.join(m3.merge_lines()), b'aaa\nbbb\n222\n') | |
|
207 | self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') | |
|
208 | 208 | |
|
209 | 209 | def test_append_b(self): |
|
210 | 210 | m3 = Merge3( |
@@ -213,7 +213,7 b' class TestMerge3(TestCase):' | |||
|
213 | 213 | [b'aaa\n', b'bbb\n', b'222\n'], |
|
214 | 214 | ) |
|
215 | 215 | |
|
216 | self.assertEqual(b''.join(m3.merge_lines()), b'aaa\nbbb\n222\n') | |
|
216 | self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') | |
|
217 | 217 | |
|
218 | 218 | def test_append_agreement(self): |
|
219 | 219 | m3 = Merge3( |
@@ -222,7 +222,7 b' class TestMerge3(TestCase):' | |||
|
222 | 222 | [b'aaa\n', b'bbb\n', b'222\n'], |
|
223 | 223 | ) |
|
224 | 224 | |
|
225 | self.assertEqual(b''.join(m3.merge_lines()), b'aaa\nbbb\n222\n') | |
|
225 | self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') | |
|
226 | 226 | |
|
227 | 227 | def test_append_clash(self): |
|
228 | 228 | m3 = Merge3( |
@@ -231,7 +231,7 b' class TestMerge3(TestCase):' | |||
|
231 | 231 | [b'aaa\n', b'bbb\n', b'333\n'], |
|
232 | 232 | ) |
|
233 | 233 | |
|
234 | ml = m3.merge_lines( | |
|
234 | ml, conflicts = m3.merge_lines( | |
|
235 | 235 | name_a=b'a', |
|
236 | 236 | name_b=b'b', |
|
237 | 237 | start_marker=b'<<', |
@@ -250,7 +250,7 b' class TestMerge3(TestCase):' | |||
|
250 | 250 | [b'aaa\n', b'222\n', b'bbb\n'], |
|
251 | 251 | ) |
|
252 | 252 | |
|
253 | ml = m3.merge_lines( | |
|
253 | ml, conflicts = m3.merge_lines( | |
|
254 | 254 | name_a=b'a', |
|
255 | 255 | name_b=b'b', |
|
256 | 256 | start_marker=b'<<', |
@@ -290,7 +290,7 b' class TestMerge3(TestCase):' | |||
|
290 | 290 | ], |
|
291 | 291 | ) |
|
292 | 292 | |
|
293 | ml = m3.merge_lines( | |
|
293 | ml, conflicts = m3.merge_lines( | |
|
294 | 294 | name_a=b'a', |
|
295 | 295 | name_b=b'b', |
|
296 | 296 | start_marker=b'<<', |
@@ -338,7 +338,7 b' bbb' | |||
|
338 | 338 | def test_merge_poem(self): |
|
339 | 339 | """Test case from diff3 manual""" |
|
340 | 340 | m3 = Merge3(TZU, LAO, TAO) |
|
341 |
ml = |
|
|
341 | ml, conflicts = m3.merge_lines(b'LAO', b'TAO') | |
|
342 | 342 | self.log(b'merge result:') |
|
343 | 343 | self.log(b''.join(ml)) |
|
344 | 344 | self.assertEqual(ml, MERGED_RESULT) |
@@ -356,11 +356,11 b' bbb' | |||
|
356 | 356 | other_text.splitlines(True), |
|
357 | 357 | this_text.splitlines(True), |
|
358 | 358 | ) |
|
359 | m_lines = m3.merge_lines(b'OTHER', b'THIS') | |
|
359 | m_lines, conflicts = m3.merge_lines(b'OTHER', b'THIS') | |
|
360 | 360 | self.assertEqual( |
|
361 | 361 | b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n' |
|
362 | 362 | b'>>>>>>> THIS\r\n'.splitlines(True), |
|
363 |
|
|
|
363 | m_lines, | |
|
364 | 364 | ) |
|
365 | 365 | |
|
366 | 366 | def test_mac_text(self): |
@@ -372,11 +372,11 b' bbb' | |||
|
372 | 372 | other_text.splitlines(True), |
|
373 | 373 | this_text.splitlines(True), |
|
374 | 374 | ) |
|
375 | m_lines = m3.merge_lines(b'OTHER', b'THIS') | |
|
375 | m_lines, conflicts = m3.merge_lines(b'OTHER', b'THIS') | |
|
376 | 376 | self.assertEqual( |
|
377 | 377 | b'<<<<<<< OTHER\rc\r=======\rb\r' |
|
378 | 378 | b'>>>>>>> THIS\r'.splitlines(True), |
|
379 |
|
|
|
379 | m_lines, | |
|
380 | 380 | ) |
|
381 | 381 | |
|
382 | 382 |
General Comments 0
You need to be logged in to leave comments.
Login now