Patchwork D6879: merge: check argument value with if/raise instead of an assert

login
register
mail settings
Submitter phabricator
Date Sept. 25, 2019, 3:57 p.m.
Message ID <ffcec5a4b270bc8d9c81e1fbf11ad968@localhost.localdomain>
Download mbox | patch
Permalink /patch/41763/
State Not Applicable
Headers show

Comments

phabricator - Sept. 25, 2019, 3:57 p.m.
Closed by commit rHG71bb9363818c: merge: check argument value with if/raise instead of an assert (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6879?vs=16607&id=16612

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

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -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.