Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/scmutil.py @ 47300:33c0c25d0b0f
errors: let each Abort subclass define its error code
It's more flexible to have the error codes defined on the error types
themselves. That way extensions can easily set their own exit code. It
also means that we can reduce a bit of duplication betwen
`scmutil.callcatch()` and `chgserver.chgcmdserver.validate()`.
Differential Revision: https://phab.mercurial-scm.org/D10735
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 18 May 2021 17:15:49 -0700 |
parents | bea4717415c0 |
children | d9c71bbe20f7 |
comparison
equal
deleted
inserted
replaced
47299:16b48ebf656e | 47300:33c0c25d0b0f |
---|---|
210 detailed_exit_code = 240 | 210 detailed_exit_code = 240 |
211 coarse_exit_code = 1 | 211 coarse_exit_code = 1 |
212 except error.WdirUnsupported: | 212 except error.WdirUnsupported: |
213 ui.error(_(b"abort: working directory revision cannot be specified\n")) | 213 ui.error(_(b"abort: working directory revision cannot be specified\n")) |
214 except error.Abort as inst: | 214 except error.Abort as inst: |
215 if isinstance(inst, (error.InputError, error.ParseError)): | 215 if inst.detailed_exit_code is not None: |
216 detailed_exit_code = 10 | 216 detailed_exit_code = inst.detailed_exit_code |
217 elif isinstance(inst, error.StateError): | |
218 detailed_exit_code = 20 | |
219 elif isinstance(inst, error.ConfigError): | |
220 detailed_exit_code = 30 | |
221 elif isinstance(inst, error.HookAbort): | |
222 detailed_exit_code = 40 | |
223 elif isinstance(inst, error.RemoteError): | |
224 detailed_exit_code = 100 | |
225 elif isinstance(inst, error.SecurityError): | |
226 detailed_exit_code = 150 | |
227 elif isinstance(inst, error.CanceledError): | |
228 detailed_exit_code = 250 | |
229 ui.error(inst.format()) | 217 ui.error(inst.format()) |
230 except error.WorkerError as inst: | 218 except error.WorkerError as inst: |
231 # Don't print a message -- the worker already should have | 219 # Don't print a message -- the worker already should have |
232 return inst.status_code | 220 return inst.status_code |
233 except ImportError as inst: | 221 except ImportError as inst: |