Commit Graph

15 Commits

Author SHA1 Message Date
Martin von Zweigbergk
c3406ac3db cleanup: use set literals
We no longer support Python 2.6, so we can now use set literals.
2017-02-10 16:56:29 -08:00
Pulkit Goyal
22dbb9466c py3: use pycompat.fsencode() to convert __file__ to bytes
__file__ returns unicodes on Python 3. This patch uses pycompat.fsencode() to
convert them to bytes.
2017-02-20 18:40:42 +05:30
Bryan O'Sullivan
6a2a31ff83 statprof: allow rendering in the Chrome trace viewer format 2017-02-12 22:20:20 -08:00
Bryan O'Sullivan
85d218ec12 statprof: add a path simplification function 2017-02-12 22:16:58 -08:00
Gregory Szorc
9c03a7696d statprof: require input file
statprof has a __main__ handler that allows viewing of previously
written data files. As Yuya pointed out during review, 82ee01726a77
broke this. This patch fixes that.
2017-01-18 22:45:07 -08:00
Pulkit Goyal
24a9271007 py3: replace os.environ with encoding.environ (part 4 of 5) 2016-12-18 02:06:00 +05:30
Pulkit Goyal
3f64a7a3eb py3: make a bytes version of getopt.getopt()
getopt.getopt() deals with unicodes on Python 3 internally and if bytes
arguments are passed, then it will return TypeError. So we have now
pycompat.getoptb() which takes bytes arguments, convert them to unicode, call
getopt.getopt() and then convert the returned value back to bytes and then
return those value.
All the instances of getopt.getopt() are replaced with pycompat.getoptb().
2016-12-06 06:36:36 +05:30
Pulkit Goyal
bf0008abe9 py3: use unicodes in __slots__
__slots__ in Python 3 accepts only unicodes and there is no harm using
unicodes in __slots__. So just adding u'' is fine. Previous occurences of this
problem are treated the same way.
2016-11-30 23:38:50 +05:30
Gregory Szorc
8ed15e9613 statprof: return state from stop()
I don't like global variables. Have stop() return the captured
state so callers can pass data to the display function.
2016-11-04 20:22:37 -07:00
Gregory Szorc
821f34cb47 statprof: pass data structure to display functions
Currently, statprof maintains a global "state" variable that is used by
several functions. Global variables hinder adaptability of code.
So pass state to display functions so we can make changes to how
"state" works in future patches.
2016-11-01 19:03:11 -07:00
Gregory Szorc
7ae9040b80 statprof: use print function 2016-08-14 19:20:12 -07:00
Gregory Szorc
62b5c735eb statprof: use absolute_imports
As part of this, we modify import order to satisfy our import
checker.
2016-11-01 18:55:30 -07:00
Gregory Szorc
9767cd7997 statprof: require paths to save or load profile data
Upstream appears to aggressively save statprof data in a well-defined
home directory path. Change the code to not do that.

We also change file saving to fail if an error has occurred
instead of silently failing. Callers can catch the exception.

This behavior is more suitable for a generic "library" module.
2016-08-14 19:14:05 -07:00
Gregory Szorc
a0c537eabf statprof: fix flake8 warnings
My local flake8 hook informed me of these warnings in the upstream
code. Fix them.
2016-08-14 19:13:32 -07:00
Gregory Szorc
e735a48987 statprof: vendor statprof.py
Vendored from https://bitbucket.org/facebook/hg-experimental
changeset 73f9db47ae5a1a9fa29a98dfe92d557ad51234c3 without
modification.

This introduces a number of code style violations. The file
already has the magic words to skip test-check-code.t. I'll
make additional changes to clean up the test-check-py3-compat.t
warnings and to change some behavior in the code that isn't
suitable for general use.

test-check-commit.t also complains about numerous things. But
there's nothing we can do if we're importing as-is.
2016-11-01 18:54:03 -07:00