##// END OF EJS Templates
simplemerge: use same newline detection for :mergediff as for :merge[3]...
Martin von Zweigbergk -
r49408:b5e1283c default
parent child Browse files
Show More
@@ -341,6 +341,15 b' def _picklabels(defaults, overrides):'
341 341 return result
342 342
343 343
344 def _detect_newline(m3):
345 if len(m3.a) > 0:
346 if m3.a[0].endswith(b'\r\n'):
347 return b'\r\n'
348 elif m3.a[0].endswith(b'\r'):
349 return b'\r'
350 return b'\n'
351
352
344 353 def render_markers(
345 354 m3,
346 355 name_a=None,
@@ -353,13 +362,8 b' def render_markers('
353 362 minimize=False,
354 363 ):
355 364 """Return merge in cvs-like form."""
365 newline = _detect_newline(m3)
356 366 conflicts = False
357 newline = b'\n'
358 if len(m3.a) > 0:
359 if m3.a[0].endswith(b'\r\n'):
360 newline = b'\r\n'
361 elif m3.a[0].endswith(b'\r'):
362 newline = b'\r'
363 367 if name_a and start_marker:
364 368 start_marker = start_marker + b' ' + name_a
365 369 if name_b and end_marker:
@@ -391,6 +395,7 b' def render_markers('
391 395
392 396
393 397 def render_mergediff(m3, name_a, name_b, name_base):
398 newline = _detect_newline(m3)
394 399 lines = []
395 400 conflicts = False
396 401 for what, group_lines in m3.merge_groups():
@@ -432,20 +437,20 b' def render_mergediff(m3, name_a, name_b,'
432 437 for line in lines2[block[2] : block[3]]:
433 438 yield b'+' + line
434 439
435 lines.append(b"<<<<<<<\n")
440 lines.append(b"<<<<<<<" + newline)
436 441 if matching_lines(a_blocks) < matching_lines(b_blocks):
437 lines.append(b"======= %s\n" % name_a)
442 lines.append(b"======= " + name_a + newline)
438 443 lines.extend(a_lines)
439 lines.append(b"------- %s\n" % name_base)
440 lines.append(b"+++++++ %s\n" % name_b)
444 lines.append(b"------- " + name_base + newline)
445 lines.append(b"+++++++ " + name_b + newline)
441 446 lines.extend(diff_lines(b_blocks, base_lines, b_lines))
442 447 else:
443 lines.append(b"------- %s\n" % name_base)
444 lines.append(b"+++++++ %s\n" % name_a)
448 lines.append(b"------- " + name_base + newline)
449 lines.append(b"+++++++ " + name_a + newline)
445 450 lines.extend(diff_lines(a_blocks, base_lines, a_lines))
446 lines.append(b"======= %s\n" % name_b)
451 lines.append(b"======= " + name_b + newline)
447 452 lines.extend(b_lines)
448 lines.append(b">>>>>>>\n")
453 lines.append(b">>>>>>>" + newline)
449 454 conflicts = True
450 455 else:
451 456 lines.extend(group_lines)
General Comments 0
You need to be logged in to leave comments. Login now