Patchwork [1,of,7] blackbox: change the way of deactivating the logger on write error

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 27, 2018, 12:57 p.m.
Message ID <ee25cad69149d0265270.1543323458@mimosa>
Download mbox | patch
Permalink /patch/36809/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 27, 2018, 12:57 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1542453830 -32400
#      Sat Nov 17 20:23:50 2018 +0900
# Node ID ee25cad69149d026527056398ec6df3f9122e5a6
# Parent  380a1f73830f0ac5925bf8a20c8c302df2176514
blackbox: change the way of deactivating the logger on write error

This prepares for the upcoming code move. The recursion guard will be ported
to the core ui.

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -159,7 +159,7 @@  class blackboxlogger(object):
 
     def _log(self, ui, event, msg, opts):
         if self._inlog:
-            # recursion and failure guard
+            # recursion guard
             return
         self._inlog = True
         default = ui.configdate('devel', 'default-date')
@@ -185,10 +185,10 @@  class blackboxlogger(object):
             with _openlogfile(ui, self._bbvfs) as fp:
                 fp.write(fmt % args)
         except (IOError, OSError) as err:
+            # deactivate this to avoid failed logging again
+            self._repo = None
             ui.debug('warning: cannot write to blackbox.log: %s\n' %
                      encoding.strtolocal(err.strerror))
-            # do not restore _inlog intentionally to avoid failed
-            # logging again
         else:
             self._inlog = False