comparison contrib/revsetbenchmarks.py @ 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
comparison
equal deleted inserted replaced
20852:b2353501d6dc 20853:95293cf67871
39 sys.stdout.write("Revision: ") 39 sys.stdout.write("Revision: ")
40 sys.stdout.flush() 40 sys.stdout.flush()
41 check_call(['hg', 'log', '--rev', str(rev), '--template', 41 check_call(['hg', 'log', '--rev', str(rev), '--template',
42 '{desc|firstline}\n']) 42 '{desc|firstline}\n'])
43 43
44 def getrevs(spec):
45 """get the list of rev matched by a revset"""
46 try:
47 out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec])
48 except CalledProcessError, exc:
49 print >> sys.stderr, "abort, can't get revision from %s" % spec
50 sys.exit(exc.returncode)
51 return [r for r in out.split() if r]
52
53
44 54
45 target_rev = sys.argv[1] 55 target_rev = sys.argv[1]
46 56
47 revsetsfile = sys.stdin 57 revsetsfile = sys.stdin
48 if len(sys.argv) > 2: 58 if len(sys.argv) > 2:
57 print "%i) %s" % (idx, rset) 67 print "%i) %s" % (idx, rset)
58 68
59 print "----------------------------" 69 print "----------------------------"
60 print 70 print
61 71
62 revs = check_output("hg log --template='{rev}\n' --rev " + target_rev,
63 shell=True)
64 72
65 revs = [r for r in revs.split() if r] 73 revs = getrevs(target_rev)
66 74
67 # Benchmark revisions
68 for r in revs: 75 for r in revs:
69 print "----------------------------" 76 print "----------------------------"
70 printrevision(r) 77 printrevision(r)
71 print "----------------------------" 78 print "----------------------------"
72 update(r) 79 update(r)