Patchwork [5,of,8] blackbox: initialize inlog flag properly

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 15, 2018, 1:02 p.m.
Message ID <2f891332b6eb05df3156.1542286966@mimosa>
Download mbox | patch
Permalink /patch/36608/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 15, 2018, 1:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1541924734 -32400
#      Sun Nov 11 17:25:34 2018 +0900
# Node ID 2f891332b6eb05df315679b3ab9e9e03c33a5293
# Parent  2d05663583476bed5a907d5c39f2850730c6e5b0
blackbox: initialize inlog flag properly

And ditch the "bb" prefix as it's no longer a ui extension class.

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -130,6 +130,7 @@  def _openlogfile(ui, vfs):
 class blackboxlogger(object):
     def __init__(self, ui):
         self._repo = None
+        self._inlog = False
         self.track = ui.configlist('blackbox', 'track')
 
     @property
@@ -158,10 +159,10 @@  class blackboxlogger(object):
         _lastlogger._log(ui, event, msg, opts)
 
     def _log(self, ui, event, msg, opts):
-        if getattr(self, '_bbinlog', False):
+        if self._inlog:
             # recursion and failure guard
             return
-        self._bbinlog = True
+        self._inlog = True
         default = ui.configdate('devel', 'default-date')
         date = dateutil.datestr(default, ui.config('blackbox', 'date-format'))
         user = procutil.getuser()
@@ -187,10 +188,10 @@  class blackboxlogger(object):
         except (IOError, OSError) as err:
             ui.debug('warning: cannot write to blackbox.log: %s\n' %
                      encoding.strtolocal(err.strerror))
-            # do not restore _bbinlog intentionally to avoid failed
+            # do not restore _inlog intentionally to avoid failed
             # logging again
         else:
-            self._bbinlog = False
+            self._inlog = False
 
     def setrepo(self, repo):
         self._repo = repo