2016-01-08 05:30:24 +03:00
|
|
|
$ extpath=`dirname $TESTDIR`
|
2016-07-08 15:15:42 +03:00
|
|
|
$ cp $extpath/hgext3rd/errorredirect.py $TESTTMP
|
2015-12-04 02:03:07 +03:00
|
|
|
$ cat > $TESTTMP/crash.py << EOF
|
|
|
|
> from mercurial import cmdutil
|
|
|
|
> cmdtable = {}
|
|
|
|
> command = cmdutil.command(cmdtable)
|
|
|
|
> @command('crash', [])
|
|
|
|
> def crash(ui, repo):
|
|
|
|
> raise 'crash'
|
|
|
|
> EOF
|
|
|
|
$ cat >> $HGRCPATH << EOF
|
|
|
|
> [extensions]
|
|
|
|
> errorredirect=$TESTTMP/errorredirect.py
|
|
|
|
> crash=$TESTTMP/crash.py
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
Test errorredirect will respect original behavior by default
|
|
|
|
$ hg init
|
|
|
|
$ hg crash 2>&1 | grep -o 'Unknown exception encountered'
|
|
|
|
Unknown exception encountered
|
|
|
|
|
|
|
|
Test the errorredirect script will override stack trace output
|
2016-04-04 22:48:01 +03:00
|
|
|
$ hg crash --config errorredirect.script='echo overridden-message'
|
|
|
|
overridden-message
|
errorredirect: wrap handlecommandexception instead of sys.exit
Summary:
Since `handlecommandexception` is in core, wrap it to suppress original
crash text, instead of doing an ugly `sys.exit()`. It's much simpler and
cleaner than before. It also fixes an issue with current chg since chgserver
will print an traceback when it encounters SystemExit.
Although `logtoprocess` are doing very similar things with `errorredirect`,
it currently cannot replace `errorredirect` because we need synchronized
behavior to return the user to their shell prompt correctly. If we can get
the synchronized behavior and a way to disable builtin warning (may be tricky)
in `logtoprocess` upstream, the `errorredirect` extension could be just a thin
wrapper around `logtoprocess` using `setconfig`.
Besides, we no longer need `suppresscommandfailure` since the feature will
be either in `errorredirect` or `logtoprocess`.
Test Plan:
Run `hg crash` with `errorredirect.script` set to confirm it is compatible
with the old behavior.
Also run unittest `test-errorredirect.t`
Reviewers: #sourcecontrol, ttung, mjpieters
Reviewed By: mjpieters
Subscribers: rmcelroy, durham, lcharignon, mjpieters
Differential Revision: https://phabricator.fb.com/D3191840
Signature: t1:3191840:1461088280:77febd539c2f38a55778af3977738c045f63a0d8
2016-04-19 20:59:22 +03:00
|
|
|
[255]
|