Show More
@@ -341,6 +341,15 b' def _picklabels(defaults, overrides):' | |||||
341 | return result |
|
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 | def render_markers( |
|
353 | def render_markers( | |
345 | m3, |
|
354 | m3, | |
346 | name_a=None, |
|
355 | name_a=None, | |
@@ -353,13 +362,8 b' def render_markers(' | |||||
353 | minimize=False, |
|
362 | minimize=False, | |
354 | ): |
|
363 | ): | |
355 | """Return merge in cvs-like form.""" |
|
364 | """Return merge in cvs-like form.""" | |
|
365 | newline = _detect_newline(m3) | |||
356 | conflicts = False |
|
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 | if name_a and start_marker: |
|
367 | if name_a and start_marker: | |
364 | start_marker = start_marker + b' ' + name_a |
|
368 | start_marker = start_marker + b' ' + name_a | |
365 | if name_b and end_marker: |
|
369 | if name_b and end_marker: | |
@@ -391,6 +395,7 b' def render_markers(' | |||||
391 |
|
395 | |||
392 |
|
396 | |||
393 | def render_mergediff(m3, name_a, name_b, name_base): |
|
397 | def render_mergediff(m3, name_a, name_b, name_base): | |
|
398 | newline = _detect_newline(m3) | |||
394 | lines = [] |
|
399 | lines = [] | |
395 | conflicts = False |
|
400 | conflicts = False | |
396 | for what, group_lines in m3.merge_groups(): |
|
401 | for what, group_lines in m3.merge_groups(): | |
@@ -432,20 +437,20 b' def render_mergediff(m3, name_a, name_b,' | |||||
432 | for line in lines2[block[2] : block[3]]: |
|
437 | for line in lines2[block[2] : block[3]]: | |
433 | yield b'+' + line |
|
438 | yield b'+' + line | |
434 |
|
439 | |||
435 |
lines.append(b"<<<<<<< |
|
440 | lines.append(b"<<<<<<<" + newline) | |
436 | if matching_lines(a_blocks) < matching_lines(b_blocks): |
|
441 | if matching_lines(a_blocks) < matching_lines(b_blocks): | |
437 |
lines.append(b"======= |
|
442 | lines.append(b"======= " + name_a + newline) | |
438 | lines.extend(a_lines) |
|
443 | lines.extend(a_lines) | |
439 |
lines.append(b"------- |
|
444 | lines.append(b"------- " + name_base + newline) | |
440 |
lines.append(b"+++++++ |
|
445 | lines.append(b"+++++++ " + name_b + newline) | |
441 | lines.extend(diff_lines(b_blocks, base_lines, b_lines)) |
|
446 | lines.extend(diff_lines(b_blocks, base_lines, b_lines)) | |
442 | else: |
|
447 | else: | |
443 |
lines.append(b"------- |
|
448 | lines.append(b"------- " + name_base + newline) | |
444 |
lines.append(b"+++++++ |
|
449 | lines.append(b"+++++++ " + name_a + newline) | |
445 | lines.extend(diff_lines(a_blocks, base_lines, a_lines)) |
|
450 | lines.extend(diff_lines(a_blocks, base_lines, a_lines)) | |
446 |
lines.append(b"======= |
|
451 | lines.append(b"======= " + name_b + newline) | |
447 | lines.extend(b_lines) |
|
452 | lines.extend(b_lines) | |
448 |
lines.append(b">>>>>>> |
|
453 | lines.append(b">>>>>>>" + newline) | |
449 | conflicts = True |
|
454 | conflicts = True | |
450 | else: |
|
455 | else: | |
451 | lines.extend(group_lines) |
|
456 | lines.extend(group_lines) |
General Comments 0
You need to be logged in to leave comments.
Login now