mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
ui: use smarttraceback
Summary: The smart traceback is generally more useful. Reviewed By: markbt Differential Revision: D18666054 fbshipit-source-id: a96bb3e2919ed6692c4a7b965ad74cd2c8a66241
This commit is contained in:
parent
1ec027f5bc
commit
cf8efdb0d2
@ -463,6 +463,7 @@ coreconfigitem("ui", "debugger", default="ipdb")
|
||||
coreconfigitem("ui", "editor", default=dynamicdefault)
|
||||
coreconfigitem("ui", "exitcodemask", default=255)
|
||||
coreconfigitem("ui", "fallbackencoding", default=None)
|
||||
coreconfigitem("ui", "fancy-traceback", default=True)
|
||||
coreconfigitem("ui", "forcecwd", default=None)
|
||||
coreconfigitem("ui", "forcemerge", default=None)
|
||||
coreconfigitem("ui", "formatdebug", default=False)
|
||||
|
@ -2395,6 +2395,9 @@ User interface controls.
|
||||
Encoding to try if it's not possible to decode the changelog using
|
||||
UTF-8. (default: ISO-8859-1)
|
||||
|
||||
``fancy-traceback``
|
||||
Render local variables in traceback. (default: True)
|
||||
|
||||
``gitignore``
|
||||
Respect ``.gitignore`` in every directory. (default: False)
|
||||
|
||||
|
@ -1292,10 +1292,14 @@ class ui(object):
|
||||
if self.tracebackflag or force:
|
||||
if exc is None:
|
||||
exc = sys.exc_info()
|
||||
fancy = self.configbool("ui", "fancy-traceback")
|
||||
cause = getattr(exc[1], "cause", None)
|
||||
|
||||
if cause is not None:
|
||||
causetb = traceback.format_tb(cause[2])
|
||||
if fancy:
|
||||
causetb = util.smarttraceback(cause[2])
|
||||
else:
|
||||
causetb = traceback.format_tb(cause[2])
|
||||
exctb = traceback.format_tb(exc[2])
|
||||
exconly = traceback.format_exception_only(cause[0], cause[1])
|
||||
|
||||
@ -1307,8 +1311,13 @@ class ui(object):
|
||||
"".join(exconly),
|
||||
)
|
||||
else:
|
||||
output = traceback.format_exception(exc[0], exc[1], exc[2])
|
||||
data = r"".join(output)
|
||||
if fancy:
|
||||
tb = util.smarttraceback(exc[2])
|
||||
output = traceback.format_exception(exc[0], exc[1], None)
|
||||
data = tb + r"".join(output)
|
||||
else:
|
||||
output = traceback.format_exception(exc[0], exc[1], exc[2])
|
||||
data = r"".join(output)
|
||||
if sys.version_info[0] >= 3:
|
||||
enc = pycompat.sysstr(encoding.encoding)
|
||||
data = data.encode(enc, errors=r"replace")
|
||||
|
@ -17,8 +17,6 @@ ensure that failing ui.atexit handlers report sensibly
|
||||
show help for a given topic or a help overview
|
||||
error in exit handlers:
|
||||
Traceback (most recent call last):
|
||||
File "*/mercurial/dispatch.py", line *, in _runexithandlers (glob)
|
||||
func(*args, **kwargs) (?)
|
||||
File "$TESTTMP/bailatexit.py", line *, in bail (glob)
|
||||
raise RuntimeError('ui.atexit handler exception')
|
||||
RuntimeError: ui.atexit handler exception
|
||||
|
@ -545,7 +545,7 @@ test python hooks
|
||||
|
||||
The second egrep is to filter out lines like ' ^', which are slightly
|
||||
different between Python 2.6 and Python 2.7.
|
||||
$ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$'
|
||||
$ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^ '
|
||||
pulling from ../a
|
||||
searching for changes
|
||||
exception from first failed import attempt:
|
||||
@ -702,7 +702,7 @@ make sure --traceback works on hook import failure
|
||||
$ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
|
||||
|
||||
$ echo a >> a
|
||||
$ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
|
||||
$ hg --traceback commit -ma 2>&1 | egrep -v '^ '
|
||||
exception from first failed import attempt:
|
||||
Traceback (most recent call last):
|
||||
ImportError: No module named somebogusmodule
|
||||
|
Loading…
Reference in New Issue
Block a user