##// END OF EJS Templates
simplemerge: split out function for rendering :merge3 conflict markers...
Martin von Zweigbergk -
r49393:e8f1414c default draft
parent child Browse files
Show More
@@ -354,11 +354,9 b' def render_markers('
354 m3,
354 m3,
355 name_a=None,
355 name_a=None,
356 name_b=None,
356 name_b=None,
357 name_base=None,
358 start_marker=b'<<<<<<<',
357 start_marker=b'<<<<<<<',
359 mid_marker=b'=======',
358 mid_marker=b'=======',
360 end_marker=b'>>>>>>>',
359 end_marker=b'>>>>>>>',
361 base_marker=None,
362 minimize=False,
360 minimize=False,
363 ):
361 ):
364 """Return merge in cvs-like form."""
362 """Return merge in cvs-like form."""
@@ -368,8 +366,6 b' def render_markers('
368 start_marker = start_marker + b' ' + name_a
366 start_marker = start_marker + b' ' + name_a
369 if name_b and end_marker:
367 if name_b and end_marker:
370 end_marker = end_marker + b' ' + name_b
368 end_marker = end_marker + b' ' + name_b
371 if name_base and base_marker:
372 base_marker = base_marker + b' ' + name_base
373 merge_groups = m3.merge_groups()
369 merge_groups = m3.merge_groups()
374 if minimize:
370 if minimize:
375 merge_groups = m3.minimize(merge_groups)
371 merge_groups = m3.minimize(merge_groups)
@@ -381,9 +377,6 b' def render_markers('
381 if start_marker is not None:
377 if start_marker is not None:
382 lines.append(start_marker + newline)
378 lines.append(start_marker + newline)
383 lines.extend(a_lines)
379 lines.extend(a_lines)
384 if base_marker is not None:
385 lines.append(base_marker + newline)
386 lines.extend(base_lines)
387 if mid_marker is not None:
380 if mid_marker is not None:
388 lines.append(mid_marker + newline)
381 lines.append(mid_marker + newline)
389 lines.extend(b_lines)
382 lines.extend(b_lines)
@@ -394,7 +387,29 b' def render_markers('
394 return lines, conflicts
387 return lines, conflicts
395
388
396
389
390 def render_merge3(m3, name_a, name_b, name_base):
391 """Render conflicts as 3-way conflict markers."""
392 newline = _detect_newline(m3)
393 conflicts = False
394 lines = []
395 for what, group_lines in m3.merge_groups():
396 if what == b'conflict':
397 base_lines, a_lines, b_lines = group_lines
398 conflicts = True
399 lines.append(b'<<<<<<< ' + name_a + newline)
400 lines.extend(a_lines)
401 lines.append(b'||||||| ' + name_base + newline)
402 lines.extend(base_lines)
403 lines.append(b'=======' + newline)
404 lines.extend(b_lines)
405 lines.append(b'>>>>>>> ' + name_b + newline)
406 else:
407 lines.extend(group_lines)
408 return lines, conflicts
409
410
397 def render_mergediff(m3, name_a, name_b, name_base):
411 def render_mergediff(m3, name_a, name_b, name_base):
412 """Render conflicts as conflict markers with one snapshot and one diff."""
398 newline = _detect_newline(m3)
413 newline = _detect_newline(m3)
399 lines = []
414 lines = []
400 conflicts = False
415 conflicts = False
@@ -504,14 +519,12 b' def simplemerge(ui, localctx, basectx, o'
504 name_a, name_b, name_base = _picklabels(opts.get('label', []))
519 name_a, name_b, name_base = _picklabels(opts.get('label', []))
505 if mode == b'mergediff':
520 if mode == b'mergediff':
506 lines, conflicts = render_mergediff(m3, name_a, name_b, name_base)
521 lines, conflicts = render_mergediff(m3, name_a, name_b, name_base)
522 elif mode == b'merge3':
523 lines, conflicts = render_merge3(m3, name_a, name_b, name_base)
507 else:
524 else:
508 extrakwargs = {
525 extrakwargs = {
509 'minimize': True,
526 'minimize': True,
510 }
527 }
511 if mode == b'merge3':
512 extrakwargs['base_marker'] = b'|||||||'
513 extrakwargs['name_base'] = name_base
514 extrakwargs['minimize'] = False
515 lines, conflicts = render_markers(
528 lines, conflicts = render_markers(
516 m3, name_a=name_a, name_b=name_b, **extrakwargs
529 m3, name_a=name_a, name_b=name_b, **extrakwargs
517 )
530 )
General Comments 0
You need to be logged in to leave comments. Login now