Show More
@@ -214,50 +214,6 b' class Merge3Text(object):' | |||
|
214 | 214 | ia = aend |
|
215 | 215 | ib = bend |
|
216 | 216 | |
|
217 | def minimize(self, merge_groups): | |
|
218 | """Trim conflict regions of lines where A and B sides match. | |
|
219 | ||
|
220 | Lines where both A and B have made the same changes at the beginning | |
|
221 | or the end of each merge region are eliminated from the conflict | |
|
222 | region and are instead considered the same. | |
|
223 | """ | |
|
224 | for what, lines in merge_groups: | |
|
225 | if what != b"conflict": | |
|
226 | yield what, lines | |
|
227 | continue | |
|
228 | base_lines, a_lines, b_lines = lines | |
|
229 | alen = len(a_lines) | |
|
230 | blen = len(b_lines) | |
|
231 | ||
|
232 | # find matches at the front | |
|
233 | ii = 0 | |
|
234 | while ii < alen and ii < blen and a_lines[ii] == b_lines[ii]: | |
|
235 | ii += 1 | |
|
236 | startmatches = ii | |
|
237 | ||
|
238 | # find matches at the end | |
|
239 | ii = 0 | |
|
240 | while ( | |
|
241 | ii < alen and ii < blen and a_lines[-ii - 1] == b_lines[-ii - 1] | |
|
242 | ): | |
|
243 | ii += 1 | |
|
244 | endmatches = ii | |
|
245 | ||
|
246 | if startmatches > 0: | |
|
247 | yield b'same', a_lines[:startmatches] | |
|
248 | ||
|
249 | yield ( | |
|
250 | b'conflict', | |
|
251 | ( | |
|
252 | base_lines, | |
|
253 | a_lines[startmatches : alen - endmatches], | |
|
254 | b_lines[startmatches : blen - endmatches], | |
|
255 | ), | |
|
256 | ) | |
|
257 | ||
|
258 | if endmatches > 0: | |
|
259 | yield b'same', a_lines[alen - endmatches :] | |
|
260 | ||
|
261 | 217 | def find_sync_regions(self): |
|
262 | 218 | """Return a list of sync regions, where both descendants match the base. |
|
263 | 219 | |
@@ -350,6 +306,49 b' def _detect_newline(m3):' | |||
|
350 | 306 | return b'\n' |
|
351 | 307 | |
|
352 | 308 | |
|
309 | def _minimize(merge_groups): | |
|
310 | """Trim conflict regions of lines where A and B sides match. | |
|
311 | ||
|
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 | |
|
314 | region and are instead considered the same. | |
|
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 | alen = len(a_lines) | |
|
322 | blen = len(b_lines) | |
|
323 | ||
|
324 | # find matches at the front | |
|
325 | ii = 0 | |
|
326 | while ii < alen and ii < blen and a_lines[ii] == b_lines[ii]: | |
|
327 | ii += 1 | |
|
328 | startmatches = ii | |
|
329 | ||
|
330 | # find matches at the end | |
|
331 | ii = 0 | |
|
332 | while ii < alen and ii < blen and a_lines[-ii - 1] == b_lines[-ii - 1]: | |
|
333 | ii += 1 | |
|
334 | endmatches = ii | |
|
335 | ||
|
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 :] | |
|
350 | ||
|
351 | ||
|
353 | 352 | def render_minimized( |
|
354 | 353 | m3, |
|
355 | 354 | name_a=None, |
@@ -366,7 +365,7 b' def render_minimized(' | |||
|
366 | 365 | if name_b: |
|
367 | 366 | end_marker = end_marker + b' ' + name_b |
|
368 | 367 | merge_groups = m3.merge_groups() |
|
369 |
merge_groups = |
|
|
368 | merge_groups = _minimize(merge_groups) | |
|
370 | 369 | lines = [] |
|
371 | 370 | for what, group_lines in merge_groups: |
|
372 | 371 | if what == b'conflict': |
General Comments 0
You need to be logged in to leave comments.
Login now