changeset 42974:71bb9363818c

merge: check argument value with if/raise instead of an assert This shouldn't make any difference for legal code, but it'll prevent the assertion from being optimized out if someone decides to do -O on our code. Differential Revision: https://phab.mercurial-scm.org/D6879
author Augie Fackler <augie@google.com>
date Wed, 25 Sep 2019 11:04:08 -0400
parents ee1ef76d7339
children 24bf7a3d3c30
files mercurial/merge.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Wed Sep 25 11:02:32 2019 -0400
+++ b/mercurial/merge.py	Wed Sep 25 11:04:08 2019 -0400
@@ -1998,10 +1998,15 @@
         # updatecheck='abort' to better suppport some of these callers.
         if updatecheck is None:
             updatecheck = UPDATECHECK_LINEAR
-        assert updatecheck in (UPDATECHECK_NONE,
+        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,
+                )))
     # If we're doing a partial update, we need to skip updating
     # the dirstate, so make a note of any partial-ness to the
     # update here.