Show More
@@ -306,18 +306,13 b' def _detect_newline(m3):' | |||||
306 | return b'\n' |
|
306 | return b'\n' | |
307 |
|
307 | |||
308 |
|
308 | |||
309 |
def _minimize( |
|
309 | def _minimize(a_lines, b_lines): | |
310 | """Trim conflict regions of lines where A and B sides match. |
|
310 | """Trim conflict regions of lines where A and B sides match. | |
311 |
|
311 | |||
312 | Lines where both A and B have made the same changes at the beginning |
|
312 | Lines where both A and B have made the same changes at the beginning | |
313 | or the end of each merge region are eliminated from the conflict |
|
313 | or the end of each merge region are eliminated from the conflict | |
314 | region and are instead considered the same. |
|
314 | region and are instead considered the same. | |
315 | """ |
|
315 | """ | |
316 | for what, lines in merge_groups: |
|
|||
317 | if what != b"conflict": |
|
|||
318 | yield what, lines |
|
|||
319 | continue |
|
|||
320 | base_lines, a_lines, b_lines = lines |
|
|||
321 |
|
|
316 | alen = len(a_lines) | |
322 |
|
|
317 | blen = len(b_lines) | |
323 |
|
318 | |||
@@ -333,20 +328,11 b' def _minimize(merge_groups):' | |||||
333 |
|
|
328 | ii += 1 | |
334 |
|
|
329 | endmatches = ii | |
335 |
|
330 | |||
336 | if startmatches > 0: |
|
331 | lines_before = a_lines[:startmatches] | |
337 | yield b'same', a_lines[:startmatches] |
|
332 | new_a_lines = a_lines[startmatches : alen - endmatches] | |
338 |
|
333 | new_b_lines = b_lines[startmatches : blen - endmatches] | ||
339 | yield ( |
|
334 | lines_after = a_lines[alen - endmatches :] | |
340 | b'conflict', |
|
335 | return lines_before, new_a_lines, new_b_lines, lines_after | |
341 | ( |
|
|||
342 | base_lines, |
|
|||
343 | a_lines[startmatches : alen - endmatches], |
|
|||
344 | b_lines[startmatches : blen - endmatches], |
|
|||
345 | ), |
|
|||
346 | ) |
|
|||
347 |
|
||||
348 | if endmatches > 0: |
|
|||
349 | yield b'same', a_lines[alen - endmatches :] |
|
|||
350 |
|
336 | |||
351 |
|
337 | |||
352 | def render_minimized( |
|
338 | def render_minimized( | |
@@ -365,17 +351,20 b' def render_minimized(' | |||||
365 | if name_b: |
|
351 | if name_b: | |
366 | end_marker = end_marker + b' ' + name_b |
|
352 | end_marker = end_marker + b' ' + name_b | |
367 | merge_groups = m3.merge_groups() |
|
353 | merge_groups = m3.merge_groups() | |
368 | merge_groups = _minimize(merge_groups) |
|
|||
369 | lines = [] |
|
354 | lines = [] | |
370 | for what, group_lines in merge_groups: |
|
355 | for what, group_lines in merge_groups: | |
371 | if what == b'conflict': |
|
356 | if what == b'conflict': | |
|
357 | conflicts = True | |||
372 | base_lines, a_lines, b_lines = group_lines |
|
358 | base_lines, a_lines, b_lines = group_lines | |
373 | conflicts = True |
|
359 | minimized = _minimize(a_lines, b_lines) | |
|
360 | lines_before, a_lines, b_lines, lines_after = minimized | |||
|
361 | lines.extend(lines_before) | |||
374 | lines.append(start_marker + newline) |
|
362 | lines.append(start_marker + newline) | |
375 | lines.extend(a_lines) |
|
363 | lines.extend(a_lines) | |
376 | lines.append(mid_marker + newline) |
|
364 | lines.append(mid_marker + newline) | |
377 | lines.extend(b_lines) |
|
365 | lines.extend(b_lines) | |
378 | lines.append(end_marker + newline) |
|
366 | lines.append(end_marker + newline) | |
|
367 | lines.extend(lines_after) | |||
379 | else: |
|
368 | else: | |
380 | lines.extend(group_lines) |
|
369 | lines.extend(group_lines) | |
381 | return lines, conflicts |
|
370 | return lines, conflicts |
General Comments 0
You need to be logged in to leave comments.
Login now