D861: commands: tidy up merge state decoding in resolve

mbthomas (Mark Thomas) phabricator at mercurial-scm.org
Mon Oct 9 21:36:38 EDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb6fa2e0d50d1: commands: tidy up merge state decoding in resolve (authored by mbthomas, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D861?vs=2365&id=2560

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4272,23 +4272,26 @@
         fm = ui.formatter('resolve', opts)
         ms = mergemod.mergestate.read(repo)
         m = scmutil.match(repo[None], pats, opts)
+
+        # Labels and keys based on merge state.  Unresolved path conflicts show
+        # as 'P'.  Resolved path conflicts show as 'R', the same as normal
+        # resolved conflicts.
+        mergestateinfo = {
+            'u': ('resolve.unresolved', 'U'),
+            'r': ('resolve.resolved', 'R'),
+            'pu': ('resolve.unresolved', 'P'),
+            'pr': ('resolve.resolved', 'R'),
+            'd': ('resolve.driverresolved', 'D'),
+        }
+
         for f in ms:
             if not m(f):
                 continue
 
-            # Set label based on merge state.
-            l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
-                              'pu': 'unresolved', 'pr': 'resolved',
-                              'd': 'driverresolved'}[ms[f]]
-
-            # Set key based on merge state.  Unresolved path conflicts show
-            # as 'P'.  Resolved path conflicts show as 'R', the same as normal
-            # resolved conflicts.
-            key = {'pu': 'P', 'pr': 'R'}.get(ms[f], ms[f].upper())
-
+            label, key = mergestateinfo[ms[f]]
             fm.startitem()
-            fm.condwrite(not nostatus, 'status', '%s ', key, label=l)
-            fm.write('path', '%s\n', f, label=l)
+            fm.condwrite(not nostatus, 'status', '%s ', key, label=label)
+            fm.write('path', '%s\n', f, label=label)
         fm.end()
         return 0
 



To: mbthomas, #hg-reviewers, dlax, ryanmce
Cc: ryanmce, mercurial-devel


More information about the Mercurial-devel mailing list