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