78
79
start_marker='<<<<<<<',
79
80
mid_marker='=======',
80
81
end_marker='>>>>>>>',
82
84
"""Return merge in cvs-like form.
86
if base_marker and reprocess:
87
raise CantReprocessAndShowBase()
85
89
start_marker = start_marker + ' ' + name_a
87
91
end_marker = end_marker + ' ' + name_b
88
92
if name_base and base_marker:
89
93
base_marker = base_marker + ' ' + name_base
91
for t in self.merge_regions():
94
merge_regions = self.merge_regions()
96
merge_regions = self.reprocess_merge_regions(merge_regions)
97
for t in merge_regions:
93
99
if what == 'unchanged':
94
100
for i in range(t[1], t[2]):
279
def reprocess_merge_regions(self, merge_regions):
280
for region in merge_regions:
281
if region[0] != "conflict":
284
type, iz, zmatch, ia, amatch, ib, bmatch = region
285
a_region = self.a[ia:amatch]
286
b_region = self.b[ib:bmatch]
287
matches = SequenceMatcher(None, a_region,
288
b_region).get_matching_blocks()
291
for region_ia, region_ib, region_len in matches[:-1]:
294
reg = self.mismatch_region(next_a, region_ia, next_b,
298
yield 'same', region_ia, region_len+region_ia
299
next_a = region_ia + region_len
300
next_b = region_ib + region_len
301
reg = self.mismatch_region(next_a, amatch, next_b, bmatch)
307
def mismatch_region(next_a, region_ia, next_b, region_ib):
308
if next_a < region_ia or next_b < region_ib:
309
return 'conflict', None, None, next_a, region_ia, next_b, region_ib
274
312
def find_sync_regions(self):
275
313
"""Return a list of sync regions, where both descendents match the base.