Patchwork [6,of,8] blackbox: extract function to test if log event is tracked

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

Comments

Yuya Nishihara - Nov. 15, 2018, 1:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1541924986 -32400
#      Sun Nov 11 17:29:46 2018 +0900
# Node ID f644f2f01fcb5444809756e121c0fafe46189f10
# Parent  2f891332b6eb05df315679b3ab9e9e03c33a5293
blackbox: extract function to test if log event is tracked

This will be a required method of the logger interface.

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -131,7 +131,7 @@  class blackboxlogger(object):
     def __init__(self, ui):
         self._repo = None
         self._inlog = False
-        self.track = ui.configlist('blackbox', 'track')
+        self._trackedevents = set(ui.configlist('blackbox', 'track'))
 
     @property
     def _bbvfs(self):
@@ -142,9 +142,12 @@  class blackboxlogger(object):
                 vfs = None
         return vfs
 
+    def tracked(self, event):
+        return b'*' in self._trackedevents or event in self._trackedevents
+
     def log(self, ui, event, msg, opts):
         global _lastlogger
-        if not '*' in self.track and not event in self.track:
+        if not self.tracked(event):
             return
 
         if self._bbvfs: