changeset 40764:567e164f89b8

blackbox: initialize logger with repo instance The blackboxlogger is unusable without a repo. Let's simply initialize it with a repo instance.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 11 Nov 2018 20:05:38 +0900
parents 3ede5d1724bb
children 7e6834ade51d
files hgext/blackbox.py
diffstat 1 files changed, 6 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/blackbox.py	Sat Nov 17 20:56:25 2018 +0900
+++ b/hgext/blackbox.py	Sun Nov 11 20:05:38 2018 +0900
@@ -139,17 +139,15 @@
 _lastlogger = proxylogger()
 
 class blackboxlogger(object):
-    def __init__(self, ui):
-        self._repo = None
+    def __init__(self, ui, repo):
+        self._repo = repo
         self._trackedevents = set(ui.configlist('blackbox', 'track'))
 
     @property
     def _bbvfs(self):
-        vfs = None
-        if self._repo:
-            vfs = self._repo.vfs
-            if not vfs.isdir('.'):
-                vfs = None
+        vfs = self._repo.vfs
+        if not vfs.isdir('.'):
+            vfs = None
         return vfs
 
     def tracked(self, event):
@@ -188,9 +186,6 @@
             ui.debug('warning: cannot write to blackbox.log: %s\n' %
                      encoding.strtolocal(err.strerror))
 
-    def setrepo(self, repo):
-        self._repo = repo
-
 def uipopulate(ui):
     ui.setlogger(b'blackbox', _lastlogger)
 
@@ -203,9 +198,8 @@
 
     # Since blackbox.log is stored in the repo directory, the logger should be
     # instantiated per repository.
-    logger = blackboxlogger(ui)
+    logger = blackboxlogger(ui, repo)
     ui.setlogger(b'blackbox', logger)
-    logger.setrepo(repo)
 
     # Set _lastlogger even if ui.log is not called. This gives blackbox a
     # fallback place to log