comparison mercurial/scmutil.py @ 47291:d9c71bbe20f7

errors: make InterventionRequired subclass Abort The docstring for `Abort` says that it's for errors raised by commands and `InterventionRequired` is definitely something raised by commands, so it seems that it should be an `Abort`. This patch makes it so. It adds a `coarse_exit_code` (in addition to the already existing `detailed_exit_code`) to `Abort` to achieve that, since `InterventionRequired` should result in a special exit code even when the `ui.detailed-exit-code` config is not set. Differential Revision: https://phab.mercurial-scm.org/D10737
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 18 May 2021 22:07:16 -0700
parents 33c0c25d0b0f
children 7a769ac49637
comparison
equal deleted inserted replaced
47290:5e736d2e9703 47291:d9c71bbe20f7
201 except error.StorageError as inst: 201 except error.StorageError as inst:
202 ui.error(_(b"abort: %s\n") % inst) 202 ui.error(_(b"abort: %s\n") % inst)
203 if inst.hint: 203 if inst.hint:
204 ui.error(_(b"(%s)\n") % inst.hint) 204 ui.error(_(b"(%s)\n") % inst.hint)
205 detailed_exit_code = 50 205 detailed_exit_code = 50
206 except error.InterventionRequired as inst:
207 ui.error(b"%s\n" % inst)
208 if inst.hint:
209 ui.error(_(b"(%s)\n") % inst.hint)
210 detailed_exit_code = 240
211 coarse_exit_code = 1
212 except error.WdirUnsupported: 206 except error.WdirUnsupported:
213 ui.error(_(b"abort: working directory revision cannot be specified\n")) 207 ui.error(_(b"abort: working directory revision cannot be specified\n"))
214 except error.Abort as inst: 208 except error.Abort as inst:
215 if inst.detailed_exit_code is not None: 209 if inst.detailed_exit_code is not None:
216 detailed_exit_code = inst.detailed_exit_code 210 detailed_exit_code = inst.detailed_exit_code
211 if inst.coarse_exit_code is not None:
212 coarse_exit_code = inst.coarse_exit_code
217 ui.error(inst.format()) 213 ui.error(inst.format())
218 except error.WorkerError as inst: 214 except error.WorkerError as inst:
219 # Don't print a message -- the worker already should have 215 # Don't print a message -- the worker already should have
220 return inst.status_code 216 return inst.status_code
221 except ImportError as inst: 217 except ImportError as inst: