ui: add support for fully printing chained exception stacks in ui.traceback()

Currently, only SubrepoAbort has a cause chained to it.
This commit is contained in:
Matt Harbison 2013-02-09 14:15:34 -05:00
parent 04524bcc4f
commit 8ab43e8c5a
2 changed files with 20 additions and 3 deletions

View File

@ -686,11 +686,23 @@ class ui(object):
only to call in exception handler. returns true if traceback
printed.'''
if self.tracebackflag:
if exc:
if exc is None:
exc = sys.exc_info()
cause = getattr(exc[1], 'cause', None)
if cause is not None:
causetb = traceback.format_tb(cause[2])
exctb = traceback.format_tb(exc[2])
exconly = traceback.format_exception_only(cause[0], cause[1])
# exclude frame where 'exc' was chained and rethrown from exctb
self.write_err('Traceback (most recent call last):\n',
''.join(exctb[:-1]),
''.join(causetb),
''.join(exconly))
else:
traceback.print_exception(exc[0], exc[1], exc[2],
file=self.ferr)
else:
traceback.print_exc(file=self.ferr)
return self.tracebackflag
def geteditor(self):

View File

@ -771,6 +771,11 @@ Create repo without default path, pull top repo, and see what happens on update
abort: default path for subrepository not found (in subrepo sub/repo) (glob)
[255]
Ensure a full traceback, not just the SubrepoAbort part
$ hg -R issue1852b update --traceback 2>&1 | grep 'raise util\.Abort'
raise util.Abort(_("default path for subrepository not found"))
Pull -u now doesn't help
$ hg -R issue1852b pull -u issue1852a