Mercurial > hg
comparison mercurial/dispatch.py @ 38022:48853a927757
dispatch: fix exit code of unhandled exception recorded in blackbox log
Spotted by Martin von Zweigbergk.
We might want to change the exit code to -1 (i.e. 255) because 1 means
non-abort error in hg, but that's another issue.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 16 May 2018 20:17:50 +0900 |
parents | 6f9ac3cb0987 |
children | c3fd9a0f8277 |
comparison
equal
deleted
inserted
replaced
38021:538e850ae737 | 38022:48853a927757 |
---|---|
206 _formatparse(ferr.write, inst) | 206 _formatparse(ferr.write, inst) |
207 return -1 | 207 return -1 |
208 | 208 |
209 msg = _formatargs(req.args) | 209 msg = _formatargs(req.args) |
210 starttime = util.timer() | 210 starttime = util.timer() |
211 ret = -1 | 211 ret = 1 # default of Python exit code on unhandled exception |
212 try: | 212 try: |
213 ret = _runcatch(req) or 0 | 213 ret = _runcatch(req) or 0 |
214 except error.ProgrammingError as inst: | 214 except error.ProgrammingError as inst: |
215 req.ui.warn(_('** ProgrammingError: %s\n') % inst) | 215 req.ui.warn(_('** ProgrammingError: %s\n') % inst) |
216 if inst.hint: | 216 if inst.hint: |
237 if req.ui.logblockedtimes: | 237 if req.ui.logblockedtimes: |
238 req.ui._blockedtimes['command_duration'] = duration * 1000 | 238 req.ui._blockedtimes['command_duration'] = duration * 1000 |
239 req.ui.log('uiblocked', 'ui blocked ms', | 239 req.ui.log('uiblocked', 'ui blocked ms', |
240 **pycompat.strkwargs(req.ui._blockedtimes)) | 240 **pycompat.strkwargs(req.ui._blockedtimes)) |
241 req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n", | 241 req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n", |
242 msg, ret or 0, duration) | 242 msg, ret, duration) |
243 try: | 243 try: |
244 req._runexithandlers() | 244 req._runexithandlers() |
245 except: # exiting, so no re-raises | 245 except: # exiting, so no re-raises |
246 ret = ret or -1 | 246 ret = ret or -1 |
247 return ret | 247 return ret |