Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 42971:ee1ef76d7339
hg: have `updatetotally` more thoroughly check updatecheck argument (API)
.. api::
`mercurial.hg.updatetotally` is now more thorough about checking
its `updatecheck` keyword argument. Previously invalid values
would have used the configured default updatecheck method, but now
will raise ValueError.
Differential Revision: https://phab.mercurial-scm.org/D6878
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 25 Sep 2019 11:02:32 -0400 |
parents | 1ad3ebb39c61 |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
42970:1ad3ebb39c61 | 42971:ee1ef76d7339 |
---|---|
881 return stats.unresolvedcount > 0 | 881 return stats.unresolvedcount > 0 |
882 | 882 |
883 # naming conflict in updatetotally() | 883 # naming conflict in updatetotally() |
884 _clean = clean | 884 _clean = clean |
885 | 885 |
886 _VALID_UPDATECHECKS = {mergemod.UPDATECHECK_ABORT, | |
887 mergemod.UPDATECHECK_NONE, | |
888 mergemod.UPDATECHECK_LINEAR, | |
889 mergemod.UPDATECHECK_NO_CONFLICT, | |
890 } | |
891 | |
886 def updatetotally(ui, repo, checkout, brev, clean=False, updatecheck=None): | 892 def updatetotally(ui, repo, checkout, brev, clean=False, updatecheck=None): |
887 """Update the working directory with extra care for non-file components | 893 """Update the working directory with extra care for non-file components |
888 | 894 |
889 This takes care of non-file components below: | 895 This takes care of non-file components below: |
890 | 896 |
909 | 915 |
910 This returns whether conflict is detected at updating or not. | 916 This returns whether conflict is detected at updating or not. |
911 """ | 917 """ |
912 if updatecheck is None: | 918 if updatecheck is None: |
913 updatecheck = ui.config('commands', 'update.check') | 919 updatecheck = ui.config('commands', 'update.check') |
914 if updatecheck not in (mergemod.UPDATECHECK_ABORT, | 920 if updatecheck not in _VALID_UPDATECHECKS: |
915 mergemod.UPDATECHECK_NONE, | |
916 mergemod.UPDATECHECK_LINEAR, | |
917 mergemod.UPDATECHECK_NO_CONFLICT): | |
918 # If not configured, or invalid value configured | 921 # If not configured, or invalid value configured |
919 updatecheck = mergemod.UPDATECHECK_LINEAR | 922 updatecheck = mergemod.UPDATECHECK_LINEAR |
923 if updatecheck not in _VALID_UPDATECHECKS: | |
924 raise ValueError(r'Invalid updatecheck value %r (can accept %r)' % ( | |
925 updatecheck, _VALID_UPDATECHECKS)) | |
920 with repo.wlock(): | 926 with repo.wlock(): |
921 movemarkfrom = None | 927 movemarkfrom = None |
922 warndest = False | 928 warndest = False |
923 if checkout is None: | 929 if checkout is None: |
924 updata = destutil.destupdate(repo, clean=clean) | 930 updata = destutil.destupdate(repo, clean=clean) |