comparison mercurial/error.py @ 45825:8f07f5a9c3de

worker: raise exception instead of calling sys.exit() with child's code When a worker process returns an error code, we would call `sys.exit()` with that exit code on the main process. The `SystemExit` exception would then get caught in `scmutil.callcatch()`, which would return that error code. The comment there says "Commands shouldn't sys.exit directly", which I agree with. This patch changes it so we raise a specific exception when a worker fails so we can catch instead. I think that means that `SystemExit` is now always an internal error. (I had earlier thought that this call to `sys.exit()` was from within the child process until Matt Harbison made me look again, so thanks for that!) Differential Revision: https://phab.mercurial-scm.org/D9287
author Martin von Zweigbergk <martinvonz@google.com>
date Sat, 07 Nov 2020 21:50:28 -0800
parents 0fc8b066928a
children 8d72e29ad1e0
comparison
equal deleted inserted replaced
45824:9ac96b9fa76e 45825:8f07f5a9c3de
126 self.prefix = prefix 126 self.prefix = prefix
127 self.matches = matches 127 self.matches = matches
128 super(AmbiguousCommand, self).__init__() 128 super(AmbiguousCommand, self).__init__()
129 129
130 __bytes__ = _tobytes 130 __bytes__ = _tobytes
131
132
133 class WorkerError(Exception):
134 """Exception raised when a worker process dies."""
135
136 def __init__(self, status_code):
137 self.status_code = status_code
131 138
132 139
133 class InterventionRequired(Hint, Exception): 140 class InterventionRequired(Hint, Exception):
134 """Exception raised when a command requires human intervention.""" 141 """Exception raised when a command requires human intervention."""
135 142