diff --git a/hgext/blackbox.py b/hgext/blackbox.py --- a/hgext/blackbox.py +++ b/hgext/blackbox.py @@ -52,7 +52,6 @@ from mercurial import ( encoding, pycompat, registrar, - ui as uimod, ) from mercurial.utils import ( dateutil, @@ -129,7 +128,6 @@ def _openlogfile(ui, vfs): class blackboxlogger(object): def __init__(self, ui): self._repo = None - self._inlog = False self._trackedevents = set(ui.configlist('blackbox', 'track')) @property @@ -158,10 +156,6 @@ class blackboxlogger(object): _lastlogger._log(ui, event, msg, opts) def _log(self, ui, event, msg, opts): - if self._inlog: - # recursion guard - return - self._inlog = True default = ui.configdate('devel', 'default-date') date = dateutil.datestr(default, ui.config('blackbox', 'date-format')) user = procutil.getuser() @@ -189,25 +183,10 @@ class blackboxlogger(object): self._repo = None ui.debug('warning: cannot write to blackbox.log: %s\n' % encoding.strtolocal(err.strerror)) - else: - self._inlog = False def setrepo(self, repo): self._repo = repo -def wrapui(ui): - class blackboxui(ui.__class__): - def debug(self, *msg, **opts): - super(blackboxui, self).debug(*msg, **opts) - if self.debugflag: - self.log('debug', '%s', ''.join(msg)) - - ui.__class__ = blackboxui - uimod.ui = blackboxui - -def uisetup(ui): - wrapui(ui) - def uipopulate(ui): ui.setlogger(b'blackbox', blackboxlogger(ui)) diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1521,6 +1521,7 @@ class ui(object): ''' if self.debugflag: self._writemsg(self._fmsgout, type='debug', *msg, **opts) + self.log(b'debug', b'%s', b''.join(msg)) def edit(self, text, user, extra=None, editform=None, pending=None, repopath=None, action=None): @@ -1740,8 +1741,14 @@ class ui(object): if l.tracked(event)] if not activeloggers: return - for logger in activeloggers: - logger.log(self, event, msg, opts) + # guard against recursion from e.g. ui.debug() + registeredloggers = self._loggers + self._loggers = {} + try: + for logger in activeloggers: + logger.log(self, event, msg, opts) + finally: + self._loggers = registeredloggers def label(self, msg, label): '''style msg based on supplied label