revsetbenchmark: convert performance call to proper subprocess call
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 26 Mar 2014 18:26:18 -0700
changeset 20851 4130ec938c84
parent 20850 d0c2535c7aba
child 20852 b2353501d6dc
revsetbenchmark: convert performance call to proper subprocess call
contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py	Wed Mar 26 18:14:15 2014 -0700
+++ b/contrib/revsetbenchmarks.py	Wed Mar 26 18:26:18 2014 -0700
@@ -25,7 +25,15 @@
         print >> sys.stderr, 'update to revision %s failed, aborting' % rev
         sys.exit(exc.returncode)
 
-PERF="./hg --config extensions.perf=contrib/perf.py perfrevset"
+def perf(revset):
+    """run benchmark for this very revset"""
+    try:
+        check_call(['./hg', '--config', 'extensions.perf=contrib/perf.py',
+                    'perfrevset', revset])
+    except CalledProcessError, exc:
+        print >> sys.stderr, 'abort: cannot run revset benchmark'
+        sys.exit(exc.returncode)
+
 
 target_rev = sys.argv[1]
 
@@ -61,6 +69,6 @@
     for idx, rset in enumerate(revsets):
         sys.stdout.write("%i) " % idx)
         sys.stdout.flush()
-        check_call(PERF + ' "%s"' % rset, shell=True)
+        perf(rset)
     print "----------------------------"