# HG changeset patch # User Vadim Gelfer # Date 1148312873 25200 # Node ID f0680b2d1d64ac6b39e9eced486bf804915bcd6b # Parent 737deea2442c63f03f2c317dac697990c3add98f add ui.print_exc(), make all traceback printing central. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3299,10 +3299,8 @@ def dispatch(args): external.append(mod) except Exception, inst: u.warn(_("*** failed to import extension %s: %s\n") % (x[0], inst)) - if u.traceback: - traceback.print_exc() + if u.print_exc(): return 1 - continue for x in external: uisetup = getattr(x, 'uisetup', None) @@ -3398,8 +3396,7 @@ def dispatch(args): # enter the debugger when we hit an exception if options['debugger']: pdb.post_mortem(sys.exc_info()[2]) - if u.traceback: - traceback.print_exc() + u.print_exc() raise except ParseError, inst: if inst.args[0]: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -12,7 +12,7 @@ from i18n import gettext as _ from demandload import * demandload(globals(), "appendfile changegroup") demandload(globals(), "re lock transaction tempfile stat mdiff errno ui") -demandload(globals(), "revlog traceback") +demandload(globals(), "revlog") class localrepository(object): def __del__(self): @@ -125,8 +125,7 @@ class localrepository(object): '%s\n') % (hname, exc)) if throw: raise - if self.ui.traceback: - traceback.print_exc() + self.ui.print_exc() return True if r: if throw: diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -9,7 +9,7 @@ import ConfigParser from i18n import gettext as _ from demandload import * demandload(globals(), "errno getpass os re smtplib socket sys tempfile") -demandload(globals(), "templater util") +demandload(globals(), "templater traceback util") class ui(object): def __init__(self, verbose=False, debug=False, quiet=False, @@ -335,3 +335,11 @@ class ui(object): else: mail = sendmail(self, method) return mail + + def print_exc(self): + '''print exception traceback if traceback printing enabled. + only to call in exception handler. returns true if traceback + printed.''' + if self.traceback: + traceback.print_exc() + return self.traceback