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