Patchwork [STABLE] statprof: require input file

login
register
mail settings
Submitter Gregory Szorc
Date Jan. 19, 2017, 7:11 a.m.
Message ID <c148ef85245edba14eff.1484809904@gps-mbp.local>
Download mbox | patch
Permalink /patch/18248/
State Accepted
Headers show

Comments

Gregory Szorc - Jan. 19, 2017, 7:11 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1484808307 28800
#      Wed Jan 18 22:45:07 2017 -0800
# Branch stable
# Node ID c148ef85245edba14eff9219e0404fc832c8305c
# Parent  94af7d0c812fe7d3a5651191685ca43e1a331814
statprof: require input file

statprof has a __main__ handler that allows viewing of previously
written data files. As Yuya pointed out during review, f42cd5434cc2
broke this. This patch fixes that.
Yuya Nishihara - Jan. 19, 2017, 1:20 p.m.
On Wed, 18 Jan 2017 23:11:44 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1484808307 28800
> #      Wed Jan 18 22:45:07 2017 -0800
> # Branch stable
> # Node ID c148ef85245edba14eff9219e0404fc832c8305c
> # Parent  94af7d0c812fe7d3a5651191685ca43e1a331814
> statprof: require input file

Queued this. Thanks for taking care of it.

Patch

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -799,8 +799,12 @@  def main(argv=None):
             return 0
         else:
             assert False, "unhandled option %s" % o
 
+    if not path:
+        print('must specify --file to load')
+        return 1
+
     load_data(path=path)
 
     display(**displayargs)
 
diff --git a/tests/test-profile.t b/tests/test-profile.t
--- a/tests/test-profile.t
+++ b/tests/test-profile.t
@@ -91,5 +91,11 @@  Various statprof formatters work
   $ hg --profile --config profiling.statformat=json sleep 2>../out
   $ cat ../out
   \[\[\d+.* (re)
 
+statprof can be used as a standalone module
+
+  $ $PYTHON -m mercurial.statprof hotpath
+  must specify --file to load
+  [1]
+
   $ cd ..