From patchwork Wed Sep 25 15:57:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D6878: hg: have `updatetotally` more thoroughly check updatecheck argument (API) From: phabricator X-Patchwork-Id: 41760 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 25 Sep 2019 15:57:05 +0000 Closed by commit rHGee1ef76d7339: hg: have `updatetotally` more thoroughly check updatecheck argument (API) (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/D6878?vs=16606&id=16611 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6878/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6878 AFFECTED FILES mercurial/hg.py CHANGE DETAILS To: durin42, #hg-reviewers, pulkit Cc: mercurial-devel diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -883,6 +883,12 @@ # naming conflict in updatetotally() _clean = clean +_VALID_UPDATECHECKS = {mergemod.UPDATECHECK_ABORT, + mergemod.UPDATECHECK_NONE, + mergemod.UPDATECHECK_LINEAR, + mergemod.UPDATECHECK_NO_CONFLICT, +} + def updatetotally(ui, repo, checkout, brev, clean=False, updatecheck=None): """Update the working directory with extra care for non-file components @@ -911,12 +917,12 @@ """ if updatecheck is None: updatecheck = ui.config('commands', 'update.check') - if updatecheck not in (mergemod.UPDATECHECK_ABORT, - mergemod.UPDATECHECK_NONE, - mergemod.UPDATECHECK_LINEAR, - mergemod.UPDATECHECK_NO_CONFLICT): + if updatecheck not in _VALID_UPDATECHECKS: # If not configured, or invalid value configured updatecheck = mergemod.UPDATECHECK_LINEAR + if updatecheck not in _VALID_UPDATECHECKS: + raise ValueError(r'Invalid updatecheck value %r (can accept %r)' % ( + updatecheck, _VALID_UPDATECHECKS)) with repo.wlock(): movemarkfrom = None warndest = False