D6525: tracing: extract tracing-active logic to separate function

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Fri Jun 14 19:16:08 EDT 2019


Closed by commit rHGd0b8a3cfd732: tracing: extract tracing-active logic to separate function (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6525?vs=15477&id=15525

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6525/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6525

AFFECTED FILES
  hgdemandimport/tracing.py

CHANGE DETAILS

diff --git a/hgdemandimport/tracing.py b/hgdemandimport/tracing.py
--- a/hgdemandimport/tracing.py
+++ b/hgdemandimport/tracing.py
@@ -13,19 +13,23 @@
 _pipe = None
 _checked = False
 
- at contextlib.contextmanager
-def log(whencefmt, *whenceargs):
+def _isactive():
     global _pipe, _session, _checked
     if _pipe is None:
         if _checked:
-            yield
-            return
+            return False
         _checked = True
         if 'HGCATAPULTSERVERPIPE' not in os.environ:
-            yield
-            return
+            return False
         _pipe = open(os.environ['HGCATAPULTSERVERPIPE'], 'w', 1)
         _session = os.environ.get('HGCATAPULTSESSION', 'none')
+    return True
+
+ at contextlib.contextmanager
+def log(whencefmt, *whenceargs):
+    if not _isactive():
+        yield
+        return
     whence = whencefmt % whenceargs
     try:
         # Both writes to the pipe are wrapped in try/except to ignore



To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list