[PATCH STABLE] statprof: require input file

Gregory Szorc gregory.szorc at gmail.com
Thu Jan 19 07:11:44 UTC 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at 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.

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 ..


More information about the Mercurial-devel mailing list