D6777: py3: make statprof's chrome output work

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Aug 31 13:35:21 EDT 2019


martinvonz edited the summary of this revision.
martinvonz retitled this revision from "py3: go back to using strings for paths in statprof.py" to "py3: make statprof's chrome output work".
martinvonz updated this revision to Diff 16347.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6777?vs=16342&id=16347

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

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

AFFECTED FILES
  mercurial/statprof.py

CHANGE DETAILS

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -759,7 +759,7 @@
 
     if path in _pathcache:
         return _pathcache[path]
-    hgpath = pycompat.fsencode(encoding.__file__).rsplit(os.sep, 2)[0]
+    hgpath = encoding.__file__.rsplit(os.sep, 2)[0]
     for p in [hgpath] + sys.path:
         prefix = p + os.sep
         if path.startswith(prefix):
@@ -807,7 +807,7 @@
         parent = stackid(stack[1:])
         myid = len(stack2id)
         stack2id[stack] = myid
-        id2stack.append(dict(category=stack[0][0], name='%s %s' % stack[0]))
+        id2stack.append(dict(category=stack[0][0], name=r'%s %s' % stack[0]))
         if parent is not None:
             id2stack[-1].update(parent=parent)
         return myid
@@ -842,7 +842,7 @@
         if minthreshold <= duration <= maxthreshold:
             # ensure no zero-duration events
             sampletime = max(oldtime + clamp, sample.time)
-            samples.append(dict(ph='E', name=oldfunc, cat=oldcat, sf=oldsid,
+            samples.append(dict(ph=r'E', name=oldfunc, cat=oldcat, sf=oldsid,
                                 ts=sampletime*1e6, pid=0))
         else:
             blacklist.add(oldidx)
@@ -851,8 +851,8 @@
     # events given only stack snapshots.
 
     for sample in data.samples:
-        stack = tuple((('%s:%d' % (simplifypath(frame.path), frame.lineno),
-                        frame.function) for frame in sample.stack))
+        stack = tuple(((r'%s:%d' % (simplifypath(pycompat.sysstr(frame.path)), frame.lineno),
+                        pycompat.sysstr(frame.function)) for frame in sample.stack))
         qstack = collections.deque(stack)
         if laststack == qstack:
             continue
@@ -866,7 +866,7 @@
             laststack.appendleft(f)
             path, name = f
             sid = stackid(tuple(laststack))
-            samples.append(dict(ph='B', name=name, cat=path, ts=sample.time*1e6,
+            samples.append(dict(ph=r'B', name=name, cat=path, ts=sample.time*1e6,
                                 sf=sid, pid=0))
         laststack = collections.deque(stack)
     while laststack:



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


More information about the Mercurial-devel mailing list