changeset 20853:95293cf67871

revsetbenchmark: get revision to benchmark in a function And move it to proper subprocess call.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 26 Mar 2014 18:36:19 -0700
parents b2353501d6dc
children bad5399c5d5f
files contrib/revsetbenchmarks.py
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/revsetbenchmarks.py	Wed Mar 26 18:27:17 2014 -0700
+++ b/contrib/revsetbenchmarks.py	Wed Mar 26 18:36:19 2014 -0700
@@ -41,6 +41,16 @@
     check_call(['hg', 'log', '--rev', str(rev), '--template',
                '{desc|firstline}\n'])
 
+def getrevs(spec):
+    """get the list of rev matched by a revset"""
+    try:
+        out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec])
+    except CalledProcessError, exc:
+        print >> sys.stderr, "abort, can't get revision from %s" % spec
+        sys.exit(exc.returncode)
+    return [r for r in out.split() if r]
+
+
 
 target_rev = sys.argv[1]
 
@@ -59,12 +69,9 @@
 print "----------------------------"
 print
 
-revs = check_output("hg log --template='{rev}\n' --rev " + target_rev,
-                    shell=True)
 
-revs = [r for r in revs.split() if r]
+revs = getrevs(target_rev)
 
-# Benchmark revisions
 for r in revs:
     print "----------------------------"
     printrevision(r)