Show More
@@ -273,7 +273,8 b' def debugbuilddag(' | |||
|
273 | 273 | ] |
|
274 | 274 | m3 = simplemerge.Merge3Text(base, local, other) |
|
275 | 275 | ml = [ |
|
276 |
l.strip() |
|
|
276 | l.strip() | |
|
277 | for l in simplemerge.render_minimized(m3)[0] | |
|
277 | 278 | ] |
|
278 | 279 | ml.append(b"") |
|
279 | 280 | elif at > 0: |
@@ -350,38 +350,33 b' def _detect_newline(m3):' | |||
|
350 | 350 | return b'\n' |
|
351 | 351 | |
|
352 | 352 | |
|
353 |
def render_m |
|
|
353 | def render_minimized( | |
|
354 | 354 | m3, |
|
355 | 355 | name_a=None, |
|
356 | 356 | name_b=None, |
|
357 | 357 | start_marker=b'<<<<<<<', |
|
358 | 358 | mid_marker=b'=======', |
|
359 | 359 | end_marker=b'>>>>>>>', |
|
360 | minimize=False, | |
|
361 | 360 | ): |
|
362 | 361 | """Return merge in cvs-like form.""" |
|
363 | 362 | newline = _detect_newline(m3) |
|
364 | 363 | conflicts = False |
|
365 |
if name_a |
|
|
364 | if name_a: | |
|
366 | 365 | start_marker = start_marker + b' ' + name_a |
|
367 |
if name_b |
|
|
366 | if name_b: | |
|
368 | 367 | end_marker = end_marker + b' ' + name_b |
|
369 | 368 | merge_groups = m3.merge_groups() |
|
370 | if minimize: | |
|
371 | merge_groups = m3.minimize(merge_groups) | |
|
369 | merge_groups = m3.minimize(merge_groups) | |
|
372 | 370 | lines = [] |
|
373 | 371 | for what, group_lines in merge_groups: |
|
374 | 372 | if what == b'conflict': |
|
375 | 373 | base_lines, a_lines, b_lines = group_lines |
|
376 | 374 | conflicts = True |
|
377 |
|
|
|
378 | lines.append(start_marker + newline) | |
|
375 | lines.append(start_marker + newline) | |
|
379 | 376 | lines.extend(a_lines) |
|
380 |
|
|
|
381 | lines.append(mid_marker + newline) | |
|
377 | lines.append(mid_marker + newline) | |
|
382 | 378 | lines.extend(b_lines) |
|
383 |
|
|
|
384 | lines.append(end_marker + newline) | |
|
379 | lines.append(end_marker + newline) | |
|
385 | 380 | else: |
|
386 | 381 | lines.extend(group_lines) |
|
387 | 382 | return lines, conflicts |
@@ -522,12 +517,7 b' def simplemerge(ui, localctx, basectx, o' | |||
|
522 | 517 | elif mode == b'merge3': |
|
523 | 518 | lines, conflicts = render_merge3(m3, name_a, name_b, name_base) |
|
524 | 519 | else: |
|
525 | extrakwargs = { | |
|
526 | 'minimize': True, | |
|
527 | } | |
|
528 | lines, conflicts = render_markers( | |
|
529 | m3, name_a=name_a, name_b=name_b, **extrakwargs | |
|
530 | ) | |
|
520 | lines, conflicts = render_minimized(m3, name_a, name_b) | |
|
531 | 521 | |
|
532 | 522 | mergedtext = b''.join(lines) |
|
533 | 523 | if opts.get('print'): |
@@ -180,7 +180,7 b' class TestMerge3(TestCase):' | |||
|
180 | 180 | self.assertEqual(list(m3.merge_regions()), [(b'a', 0, 2)]) |
|
181 | 181 | |
|
182 | 182 | self.assertEqual( |
|
183 |
simplemerge.render_m |
|
|
183 | simplemerge.render_minimized(m3), ([b'aaa', b'bbb'], False) | |
|
184 | 184 | ) |
|
185 | 185 | |
|
186 | 186 | def test_no_conflicts(self): |
@@ -207,7 +207,7 b' class TestMerge3(TestCase):' | |||
|
207 | 207 | ) |
|
208 | 208 | |
|
209 | 209 | self.assertEqual( |
|
210 |
b''.join(simplemerge.render_m |
|
|
210 | b''.join(simplemerge.render_minimized(m3)[0]), b'aaa\nbbb\n222\n' | |
|
211 | 211 | ) |
|
212 | 212 | |
|
213 | 213 | def test_append_b(self): |
@@ -218,7 +218,7 b' class TestMerge3(TestCase):' | |||
|
218 | 218 | ) |
|
219 | 219 | |
|
220 | 220 | self.assertEqual( |
|
221 |
b''.join(simplemerge.render_m |
|
|
221 | b''.join(simplemerge.render_minimized(m3)[0]), b'aaa\nbbb\n222\n' | |
|
222 | 222 | ) |
|
223 | 223 | |
|
224 | 224 | def test_append_agreement(self): |
@@ -229,7 +229,7 b' class TestMerge3(TestCase):' | |||
|
229 | 229 | ) |
|
230 | 230 | |
|
231 | 231 | self.assertEqual( |
|
232 |
b''.join(simplemerge.render_m |
|
|
232 | b''.join(simplemerge.render_minimized(m3)[0]), b'aaa\nbbb\n222\n' | |
|
233 | 233 | ) |
|
234 | 234 | |
|
235 | 235 | def test_append_clash(self): |
@@ -239,7 +239,7 b' class TestMerge3(TestCase):' | |||
|
239 | 239 | [b'aaa\n', b'bbb\n', b'333\n'], |
|
240 | 240 | ) |
|
241 | 241 | |
|
242 |
ml, conflicts = simplemerge.render_m |
|
|
242 | ml, conflicts = simplemerge.render_minimized( | |
|
243 | 243 | m3, |
|
244 | 244 | name_a=b'a', |
|
245 | 245 | name_b=b'b', |
@@ -259,7 +259,7 b' class TestMerge3(TestCase):' | |||
|
259 | 259 | [b'aaa\n', b'222\n', b'bbb\n'], |
|
260 | 260 | ) |
|
261 | 261 | |
|
262 |
ml, conflicts = simplemerge.render_m |
|
|
262 | ml, conflicts = simplemerge.render_minimized( | |
|
263 | 263 | m3, |
|
264 | 264 | name_a=b'a', |
|
265 | 265 | name_b=b'b', |
@@ -300,7 +300,7 b' class TestMerge3(TestCase):' | |||
|
300 | 300 | ], |
|
301 | 301 | ) |
|
302 | 302 | |
|
303 |
ml, conflicts = simplemerge.render_m |
|
|
303 | ml, conflicts = simplemerge.render_minimized( | |
|
304 | 304 | m3, |
|
305 | 305 | name_a=b'a', |
|
306 | 306 | name_b=b'b', |
@@ -349,7 +349,7 b' bbb' | |||
|
349 | 349 | def test_merge_poem(self): |
|
350 | 350 | """Test case from diff3 manual""" |
|
351 | 351 | m3 = Merge3(TZU, LAO, TAO) |
|
352 |
ml, conflicts = simplemerge.render_m |
|
|
352 | ml, conflicts = simplemerge.render_minimized(m3, b'LAO', b'TAO') | |
|
353 | 353 | self.log(b'merge result:') |
|
354 | 354 | self.log(b''.join(ml)) |
|
355 | 355 | self.assertEqual(ml, MERGED_RESULT) |
@@ -367,7 +367,7 b' bbb' | |||
|
367 | 367 | other_text.splitlines(True), |
|
368 | 368 | this_text.splitlines(True), |
|
369 | 369 | ) |
|
370 |
m_lines, conflicts = simplemerge.render_m |
|
|
370 | m_lines, conflicts = simplemerge.render_minimized(m3, b'OTHER', b'THIS') | |
|
371 | 371 | self.assertEqual( |
|
372 | 372 | b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n' |
|
373 | 373 | b'>>>>>>> THIS\r\n'.splitlines(True), |
@@ -383,7 +383,7 b' bbb' | |||
|
383 | 383 | other_text.splitlines(True), |
|
384 | 384 | this_text.splitlines(True), |
|
385 | 385 | ) |
|
386 |
m_lines, conflicts = simplemerge.render_m |
|
|
386 | m_lines, conflicts = simplemerge.render_minimized(m3, b'OTHER', b'THIS') | |
|
387 | 387 | self.assertEqual( |
|
388 | 388 | b'<<<<<<< OTHER\rc\r=======\rb\r' |
|
389 | 389 | b'>>>>>>> THIS\r'.splitlines(True), |
General Comments 0
You need to be logged in to leave comments.
Login now