##// END OF EJS Templates
merge: introduce method to minimize merge regions...
Ryan McElroy -
r28071:261324dd default
parent child Browse files
Show More
@@ -269,6 +269,45 b' class Merge3Text(object):'
269 ia = aend
269 ia = aend
270 ib = bend
270 ib = bend
271
271
272 def minimize(self, merge_regions):
273 """Trim conflict regions of lines where A and B sides match.
274
275 Lines where both A and B have made the same changes at the begining
276 or the end of each merge region are eliminated from the conflict
277 region and are instead considered the same.
278 """
279 for region in merge_regions:
280 if region[0] != "conflict":
281 yield region
282 continue
283 issue, z1, z2, a1, a2, b1, b2 = region
284 alen = a2 - a1
285 blen = b2 - b1
286
287 # find matches at the front
288 ii = 0
289 while ii < alen and ii < blen and \
290 self.a[a1 + ii] == self.b[b1 + ii]:
291 ii += 1
292 startmatches = ii
293
294 # find matches at the end
295 ii = 0
296 while ii < alen and ii < blen and \
297 self.a[a2 - ii - 1] == self.b[b2 - ii - 1]:
298 ii += 1
299 endmatches = ii
300
301 if startmatches > 0:
302 yield 'same', a1, a1 + startmatches
303
304 yield ('conflict', z1, z2,
305 a1 + startmatches, a2 - endmatches,
306 b1 + startmatches, b2 - endmatches)
307
308 if endmatches > 0:
309 yield 'same', a2 - endmatches, a2
310
272 def find_sync_regions(self):
311 def find_sync_regions(self):
273 """Return a list of sync regions, where both descendants match the base.
312 """Return a list of sync regions, where both descendants match the base.
274
313
General Comments 0
You need to be logged in to leave comments. Login now