D7108: cleanup: hgdemandimport.tracing accepts strings, not bytes

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Tue Oct 15 15:23:44 UTC 2019


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This does mean that the resulting traces will have some b'' goo in them on
  Python 3, but I think that's a worthwile price to pay since it doesn't break
  any tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/dispatch.py
  mercurial/extensions.py
  mercurial/exthelper.py
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -185,12 +185,12 @@
     for f in presetupfuncs or []:
         f(ui, obj)
     ui.log(b'extension', b'- executing reposetup hooks\n')
-    with util.timedcm(b'all reposetup') as allreposetupstats:
+    with util.timedcm('all reposetup') as allreposetupstats:
         for name, module in extensions.extensions(ui):
             ui.log(b'extension', b'  - running reposetup for %s\n', name)
             hook = getattr(module, 'reposetup', None)
             if hook:
-                with util.timedcm(b'reposetup %r', name) as stats:
+                with util.timedcm('reposetup %r', name) as stats:
                     hook(ui, obj)
                 ui.log(
                     b'extension', b'  > reposetup for %s took %s\n', name, stats
diff --git a/mercurial/exthelper.py b/mercurial/exthelper.py
--- a/mercurial/exthelper.py
+++ b/mercurial/exthelper.py
@@ -139,7 +139,7 @@
         for cont, funcname, wrapper in self._functionwrappers:
             extensions.wrapfunction(cont, funcname, wrapper)
         for c in self._uicallables:
-            with tracing.log(b'finaluisetup: %s', pycompat.sysbytes(repr(c))):
+            with tracing.log('finaluisetup: %s', repr(c)):
                 c(ui)
 
     def finaluipopulate(self, ui):
@@ -180,7 +180,7 @@
                     entry[1].append(opt)
 
         for c in self._extcallables:
-            with tracing.log(b'finalextsetup: %s', pycompat.sysbytes(repr(c))):
+            with tracing.log('finalextsetup: %s', repr(c)):
                 c(ui)
 
     def finalreposetup(self, ui, repo):
@@ -193,7 +193,7 @@
         - Changes to repo.__class__, repo.dirstate.__class__
         """
         for c in self._repocallables:
-            with tracing.log(b'finalreposetup: %s', pycompat.sysbytes(repr(c))):
+            with tracing.log('finalreposetup: %s', repr(c)):
                 c(ui, repo)
 
     def uisetup(self, call):
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -207,7 +207,7 @@
         return _extensions[shortname]
     ui.log(b'extension', b'  - loading extension: %s\n', shortname)
     _extensions[shortname] = None
-    with util.timedcm(b'load extension %s', shortname) as stats:
+    with util.timedcm('load extension %s', shortname) as stats:
         mod = _importext(name, path, bind(_reportimporterror, ui))
     ui.log(b'extension', b'  > %s extension loaded in %s\n', shortname, stats)
     if loadingtime is not None:
@@ -233,7 +233,7 @@
     ui.log(
         b'extension', b'    - invoking registered callbacks: %s\n', shortname
     )
-    with util.timedcm(b'callbacks extension %s', shortname) as stats:
+    with util.timedcm('callbacks extension %s', shortname) as stats:
         for fn in _aftercallbacks.get(shortname, []):
             fn(loaded=True)
     ui.log(b'extension', b'    > callbacks completed in %s\n', stats)
@@ -278,7 +278,7 @@
         b'additional ' if newindex else b'',
     )
     ui.log(b'extension', b'- processing %d entries\n', len(result))
-    with util.timedcm(b'load all extensions') as stats:
+    with util.timedcm('load all extensions') as stats:
         for (name, path) in result:
             if path:
                 if path[0:1] == b'!':
@@ -331,10 +331,10 @@
 
     broken = set()
     ui.log(b'extension', b'- executing uisetup hooks\n')
-    with util.timedcm(b'all uisetup') as alluisetupstats:
+    with util.timedcm('all uisetup') as alluisetupstats:
         for name in _order[newindex:]:
             ui.log(b'extension', b'  - running uisetup for %s\n', name)
-            with util.timedcm(b'uisetup %s', name) as stats:
+            with util.timedcm('uisetup %s', name) as stats:
                 if not _runuisetup(name, ui):
                     ui.log(
                         b'extension',
@@ -347,12 +347,12 @@
     ui.log(b'extension', b'> all uisetup took %s\n', alluisetupstats)
 
     ui.log(b'extension', b'- executing extsetup hooks\n')
-    with util.timedcm(b'all extsetup') as allextetupstats:
+    with util.timedcm('all extsetup') as allextetupstats:
         for name in _order[newindex:]:
             if name in broken:
                 continue
             ui.log(b'extension', b'  - running extsetup for %s\n', name)
-            with util.timedcm(b'extsetup %s', name) as stats:
+            with util.timedcm('extsetup %s', name) as stats:
                 if not _runextsetup(name, ui):
                     ui.log(
                         b'extension',
@@ -370,7 +370,7 @@
 
     # Call aftercallbacks that were never met.
     ui.log(b'extension', b'- executing remaining aftercallbacks\n')
-    with util.timedcm(b'aftercallbacks') as stats:
+    with util.timedcm('aftercallbacks') as stats:
         for shortname in _aftercallbacks:
             if shortname in _extensions:
                 continue
@@ -417,7 +417,7 @@
         (b'templatefunc', templatefuncs, b'loadfunction'),
         (b'templatekeyword', templatekw, b'loadkeyword'),
     ]
-    with util.timedcm(b'load registration objects') as stats:
+    with util.timedcm('load registration objects') as stats:
         _loadextra(ui, newindex, extraloaders)
     ui.log(
         b'extension',
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -104,7 +104,7 @@
 def run():
     b"run the command in sys.argv"
     initstdio()
-    with tracing.log(b'parse args into request'):
+    with tracing.log('parse args into request'):
         req = request(pycompat.sysargv[1:])
     err = None
     try:
@@ -210,7 +210,7 @@
 
 def dispatch(req):
     """run the command specified in req.args; returns an integer status code"""
-    with tracing.log(b'dispatch.dispatch'):
+    with tracing.log('dispatch.dispatch'):
         if req.ferr:
             ferr = req.ferr
         elif req.ui:
@@ -297,7 +297,7 @@
 
 
 def _runcatch(req):
-    with tracing.log(b'dispatch._runcatch'):
+    with tracing.log('dispatch._runcatch'):
 
         def catchterm(*args):
             raise error.SignalInterrupt
@@ -1181,7 +1181,7 @@
 def _runcommand(ui, options, cmd, cmdfunc):
     """Run a command function, possibly with profiling enabled."""
     try:
-        with tracing.log(b"Running %s command" % cmd):
+        with tracing.log("Running %s command" % cmd):
             return cmdfunc()
     except error.SignatureError:
         raise error.CommandError(cmd, _(b'invalid arguments'))
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -950,7 +950,7 @@
 
     remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
     localrevs = opts[b'rev']
-    with util.timedcm(b'debug-discovery') as t:
+    with util.timedcm('debug-discovery') as t:
         common, hds = doit(localrevs, remoterevs)
 
     # compute all statistics



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


More information about the Mercurial-devel mailing list