diff -r c93d046d4300 -r 55b053af7196 hgext/blackbox.py --- a/hgext/blackbox.py Mon Nov 12 21:10:51 2018 +0900 +++ b/hgext/blackbox.py Sun Nov 11 18:08:33 2018 +0900 @@ -53,7 +53,6 @@ pycompat, registrar, ui as uimod, - util, ) from mercurial.utils import ( dateutil, @@ -147,9 +146,6 @@ def log(self, ui, event, msg, opts): global _lastlogger - if not self.tracked(event): - return - if self._bbvfs: _lastlogger = self elif _lastlogger and _lastlogger._bbvfs: @@ -201,33 +197,20 @@ def wrapui(ui): class blackboxui(ui.__class__): - def __init__(self, src=None): - super(blackboxui, self).__init__(src) - if src and r'_bblogger' in src.__dict__: - self._bblogger = src._bblogger - - # trick to initialize logger after configuration is loaded, which - # can be replaced later with blackboxlogger(ui) in uisetup(), where - # both user and repo configurations should be available. - @util.propertycache - def _bblogger(self): - return blackboxlogger(self) - def debug(self, *msg, **opts): super(blackboxui, self).debug(*msg, **opts) if self.debugflag: self.log('debug', '%s', ''.join(msg)) - def log(self, event, *msg, **opts): - super(blackboxui, self).log(event, *msg, **opts) - self._bblogger.log(self, event, msg, opts) - ui.__class__ = blackboxui uimod.ui = blackboxui def uisetup(ui): wrapui(ui) +def uipopulate(ui): + ui.setlogger(b'blackbox', blackboxlogger(ui)) + def reposetup(ui, repo): # During 'hg pull' a httppeer repo is created to represent the remote repo. # It doesn't have a .hg directory to put a blackbox in, so we don't do @@ -235,7 +218,10 @@ if not repo.local(): return - logger = getattr(ui, '_bblogger', None) + # Since blackbox.log is stored in the repo directory, the logger should be + # instantiated per repository. + logger = blackboxlogger(ui) + ui.setlogger(b'blackbox', logger) if logger: logger.setrepo(repo)