[Updated] D12106: merge: break up two not-so-one-liner for extra readability

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Fri Feb 4 10:29:25 UTC 2022


Closed by commit rHG6c4b10d01af0: merge: break up two not-so-one-liner for extra readability (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D12106?vs=32002&id=32064

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

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1885,22 +1885,11 @@
         # updatecheck='abort' to better suppport some of these callers.
         if updatecheck is None:
             updatecheck = UPDATECHECK_LINEAR
-        if updatecheck not in (
-            UPDATECHECK_NONE,
-            UPDATECHECK_LINEAR,
-            UPDATECHECK_NO_CONFLICT,
-        ):
-            raise ValueError(
-                r'Invalid updatecheck %r (can accept %r)'
-                % (
-                    updatecheck,
-                    (
-                        UPDATECHECK_NONE,
-                        UPDATECHECK_LINEAR,
-                        UPDATECHECK_NO_CONFLICT,
-                    ),
-                )
-            )
+        okay = (UPDATECHECK_NONE, UPDATECHECK_LINEAR, UPDATECHECK_NO_CONFLICT)
+        if updatecheck not in okay:
+            msg = r'Invalid updatecheck %r (can accept %r)'
+            msg %= (updatecheck, okay)
+            raise ValueError(msg)
     if wc is not None and wc.isinmemory():
         maybe_wlock = util.nullcontextmanager()
     else:
@@ -1929,10 +1918,9 @@
                 raise error.StateError(_(b"outstanding uncommitted merge"))
             ms = wc.mergestate()
             if ms.unresolvedcount():
-                raise error.StateError(
-                    _(b"outstanding merge conflicts"),
-                    hint=_(b"use 'hg resolve' to resolve"),
-                )
+                msg = _(b"outstanding merge conflicts")
+                hint = _(b"use 'hg resolve' to resolve")
+                raise error.StateError(msg, hint=hint)
         if branchmerge:
             if pas == [p2]:
                 raise error.Abort(



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


More information about the Mercurial-patches mailing list