sapling/tests/test-morecolors.t
Jun Wu 605fa025ff morecolors: colorize uncaught exceptions
Summary:
Previously morecolors only changes "ui.traceback". This diff makes it replace
uncaught exceptions. It now conflicts with errorredirect (whichever loads last
will be effective) but that's probably fine since morecolors is intended for
the team only.

Test Plan: Added a test case.

Reviewers: #mercurial, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir, medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5347030

Signature: t1:5347030:1498751985:b8c750c5bfe4a25f1e0a4dd1cebcfa74fa8739b0
2017-06-29 09:55:25 -07:00

40 lines
1.1 KiB
Perl

$ cat >> $HGRCPATH << EOF
> [extensions]
> morecolors=$TESTDIR/../hgext3rd/morecolors.py
> [ui]
> color=always
> [color]
> mode=ansi
> EOF
Traceback has color:
$ cat > repocrash.py << EOF
> from mercurial import error
> def reposetup(ui, repo):
> raise error.Abort('.')
> EOF
$ hg init repo1
$ cd repo1
$ hg commit --config extensions.repocrash=$TESTTMP/repocrash.py --traceback 2>&1 | egrep -v '^ '
Traceback (most recent call last):
\x1b[0;31;1m File "$TESTTMP/repocrash.py", line 3, in reposetup\x1b[0m (esc)
\x1b[0;31;1m raise error.Abort('.')\x1b[0m (esc)
\x1b[0;31;1mAbort: .\x1b[0m (esc)
abort: .
Uncaught exception has color:
$ cat > $TESTTMP/uncaughtcrash.py <<EOF
> def reposetup(ui, repo):
> raise RuntimeError('.')
> EOF
$ hg commit --config extensions.repocrash=$TESTTMP/uncaughtcrash.py 2>&1 | egrep -v '^ '
Traceback (most recent call last):
\x1b[0;31;1m File "$TESTTMP/uncaughtcrash.py", line 2, in reposetup\x1b[0m (esc)
\x1b[0;31;1m raise RuntimeError('.')\x1b[0m (esc)
\x1b[0;31;1mRuntimeError: .\x1b[0m (esc)