Mercurial > public > mercurial-scm > hg
comparison contrib/revsetbenchmarks.py @ 20850:d0c2535c7aba
revsetbenchmark: convert update to proper subprocess call
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 26 Mar 2014 18:14:15 -0700 |
parents | 5abc2562106a |
children | 4130ec938c84 |
comparison
equal
deleted
inserted
replaced
20849:5abc2562106a | 20850:d0c2535c7aba |
---|---|
12 # | 12 # |
13 # This script also does one run of the current version of mercurial installed | 13 # This script also does one run of the current version of mercurial installed |
14 # to compare performance. | 14 # to compare performance. |
15 | 15 |
16 import sys | 16 import sys |
17 from subprocess import check_call, check_output | 17 from subprocess import check_call, check_output, CalledProcessError |
18 | 18 |
19 HG="hg update --quiet --check" | 19 |
20 def update(rev): | |
21 """update the repo to a revision""" | |
22 try: | |
23 check_call(['hg', 'update', '--quiet', '--check', str(rev)]) | |
24 except CalledProcessError, exc: | |
25 print >> sys.stderr, 'update to revision %s failed, aborting' % rev | |
26 sys.exit(exc.returncode) | |
27 | |
20 PERF="./hg --config extensions.perf=contrib/perf.py perfrevset" | 28 PERF="./hg --config extensions.perf=contrib/perf.py perfrevset" |
21 | 29 |
22 target_rev = sys.argv[1] | 30 target_rev = sys.argv[1] |
23 | 31 |
24 revsetsfile = sys.stdin | 32 revsetsfile = sys.stdin |
47 sys.stdout.write("Revision: ") | 55 sys.stdout.write("Revision: ") |
48 sys.stdout.flush() | 56 sys.stdout.flush() |
49 check_call('hg log -r %s --template "{desc|firstline}\n"' % r, shell=True) | 57 check_call('hg log -r %s --template "{desc|firstline}\n"' % r, shell=True) |
50 | 58 |
51 print "----------------------------" | 59 print "----------------------------" |
52 check_call(HG + ' ' + r, shell=True) | 60 update(r) |
53 for idx, rset in enumerate(revsets): | 61 for idx, rset in enumerate(revsets): |
54 sys.stdout.write("%i) " % idx) | 62 sys.stdout.write("%i) " % idx) |
55 sys.stdout.flush() | 63 sys.stdout.flush() |
56 check_call(PERF + ' "%s"' % rset, shell=True) | 64 check_call(PERF + ' "%s"' % rset, shell=True) |
57 print "----------------------------" | 65 print "----------------------------" |