Mercurial > hg
diff mercurial/simplemerge.py @ 48547:374bf34c9ffd
simplemerge: make merge_groups() yield only 2-tuples
`merge_groups()` currently yields 2-tuples or 4-tuples, making the
callers check the first element to decide how to interpret the
rest. Let's make it yield only 2-tuples, thereby simplifying life a
little for the callers.
Differential Revision: https://phab.mercurial-scm.org/D11966
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 06 Jan 2022 09:03:17 -0800 |
parents | 59524cb1cd73 |
children | 88a45330b290 |
line wrap: on
line diff
--- a/mercurial/simplemerge.py Fri Jan 07 14:40:21 2022 +0100 +++ b/mercurial/simplemerge.py Thu Jan 06 09:03:17 2022 -0800 @@ -160,7 +160,7 @@ 'b', lines Lines taken from b - 'conflict', base_lines, a_lines, b_lines + 'conflict', (base_lines, a_lines, b_lines) Lines from base were changed to either a or b and conflict. """ for t in self.merge_regions(): @@ -174,9 +174,11 @@ elif what == b'conflict': yield ( what, - self.base[t[1] : t[2]], - self.a[t[3] : t[4]], - self.b[t[5] : t[6]], + ( + self.base[t[1] : t[2]], + self.a[t[3] : t[4]], + self.b[t[5] : t[6]], + ), ) else: raise ValueError(what) @@ -417,9 +419,9 @@ def _mergediff(m3, name_a, name_b, name_base): lines = [] conflicts = False - for group in m3.merge_groups(): - if group[0] == b'conflict': - base_lines, a_lines, b_lines = group[1:] + for what, group_lines in m3.merge_groups(): + if what == b'conflict': + base_lines, a_lines, b_lines = group_lines base_text = b''.join(base_lines) b_blocks = list( mdiff.allblocks( @@ -472,18 +474,18 @@ lines.append(b">>>>>>>\n") conflicts = True else: - lines.extend(group[1]) + lines.extend(group_lines) return lines, conflicts def _resolve(m3, sides): lines = [] - for group in m3.merge_groups(): - if group[0] == b'conflict': + for what, group_lines in m3.merge_groups(): + if what == b'conflict': for side in sides: - lines.extend(group[side + 1]) + lines.extend(group_lines[side]) else: - lines.extend(group[1]) + lines.extend(group_lines) return lines