# HG changeset patch # User Pierre-Yves David # Date 2014-03-27 01:36:19 # Node ID 95293cf67871aa7689acaa9d03250071184eff27 # Parent b2353501d6dc02a7246b493585d95ded922f0b5c revsetbenchmark: get revision to benchmark in a function And move it to proper subprocess call. diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py --- a/contrib/revsetbenchmarks.py +++ b/contrib/revsetbenchmarks.py @@ -41,6 +41,16 @@ def printrevision(rev): 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 @@ for idx, rset in enumerate(revsets): 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)