[Updated] D11966: simplemerge: make merge_groups() yield only 2-tuples

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Jan 7 11:09:55 UTC 2022


Closed by commit rHG9e2355cc5e69: simplemerge: make merge_groups() yield only 2-tuples (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11966?vs=31606&id=31619

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11966/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11966

AFFECTED FILES
  mercurial/simplemerge.py
  tests/test-simplemerge.py

CHANGE DETAILS

diff --git a/tests/test-simplemerge.py b/tests/test-simplemerge.py
--- a/tests/test-simplemerge.py
+++ b/tests/test-simplemerge.py
@@ -285,7 +285,7 @@
             list(m3.merge_groups()),
             [
                 (b'unchanged', [b'aaa\n']),
-                (b'conflict', [], [b'111\n'], [b'222\n']),
+                (b'conflict', ([], [b'111\n'], [b'222\n'])),
                 (b'unchanged', [b'bbb\n']),
             ],
         )
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -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
 
 



To: martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220107/a2bfd3a9/attachment-0002.html>


More information about the Mercurial-patches mailing list