##// END OF EJS Templates
simplemerge: make merge_groups() yield only 2-tuples...
Martin von Zweigbergk -
r49379:374bf34c default
parent child Browse files
Show More
@@ -160,7 +160,7 b' class Merge3Text(object):'
160 'b', lines
160 'b', lines
161 Lines taken from b
161 Lines taken from b
162
162
163 'conflict', base_lines, a_lines, b_lines
163 'conflict', (base_lines, a_lines, b_lines)
164 Lines from base were changed to either a or b and conflict.
164 Lines from base were changed to either a or b and conflict.
165 """
165 """
166 for t in self.merge_regions():
166 for t in self.merge_regions():
@@ -174,9 +174,11 b' class Merge3Text(object):'
174 elif what == b'conflict':
174 elif what == b'conflict':
175 yield (
175 yield (
176 what,
176 what,
177 (
177 self.base[t[1] : t[2]],
178 self.base[t[1] : t[2]],
178 self.a[t[3] : t[4]],
179 self.a[t[3] : t[4]],
179 self.b[t[5] : t[6]],
180 self.b[t[5] : t[6]],
181 ),
180 )
182 )
181 else:
183 else:
182 raise ValueError(what)
184 raise ValueError(what)
@@ -417,9 +419,9 b' def _picklabels(defaults, overrides):'
417 def _mergediff(m3, name_a, name_b, name_base):
419 def _mergediff(m3, name_a, name_b, name_base):
418 lines = []
420 lines = []
419 conflicts = False
421 conflicts = False
420 for group in m3.merge_groups():
422 for what, group_lines in m3.merge_groups():
421 if group[0] == b'conflict':
423 if what == b'conflict':
422 base_lines, a_lines, b_lines = group[1:]
424 base_lines, a_lines, b_lines = group_lines
423 base_text = b''.join(base_lines)
425 base_text = b''.join(base_lines)
424 b_blocks = list(
426 b_blocks = list(
425 mdiff.allblocks(
427 mdiff.allblocks(
@@ -472,18 +474,18 b' def _mergediff(m3, name_a, name_b, name_'
472 lines.append(b">>>>>>>\n")
474 lines.append(b">>>>>>>\n")
473 conflicts = True
475 conflicts = True
474 else:
476 else:
475 lines.extend(group[1])
477 lines.extend(group_lines)
476 return lines, conflicts
478 return lines, conflicts
477
479
478
480
479 def _resolve(m3, sides):
481 def _resolve(m3, sides):
480 lines = []
482 lines = []
481 for group in m3.merge_groups():
483 for what, group_lines in m3.merge_groups():
482 if group[0] == b'conflict':
484 if what == b'conflict':
483 for side in sides:
485 for side in sides:
484 lines.extend(group[side + 1])
486 lines.extend(group_lines[side])
485 else:
487 else:
486 lines.extend(group[1])
488 lines.extend(group_lines)
487 return lines
489 return lines
488
490
489
491
@@ -285,7 +285,7 b' class TestMerge3(TestCase):'
285 list(m3.merge_groups()),
285 list(m3.merge_groups()),
286 [
286 [
287 (b'unchanged', [b'aaa\n']),
287 (b'unchanged', [b'aaa\n']),
288 (b'conflict', [], [b'111\n'], [b'222\n']),
288 (b'conflict', ([], [b'111\n'], [b'222\n'])),
289 (b'unchanged', [b'bbb\n']),
289 (b'unchanged', [b'bbb\n']),
290 ],
290 ],
291 )
291 )
General Comments 0
You need to be logged in to leave comments. Login now