revsetbenchmark: convert update to proper subprocess call
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 26 Mar 2014 18:14:15 -0700
changeset 20850 d0c2535c7aba
parent 20849 5abc2562106a
child 20851 4130ec938c84
revsetbenchmark: convert update to proper subprocess call
contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py	Thu Mar 27 16:52:24 2014 -0500
+++ b/contrib/revsetbenchmarks.py	Wed Mar 26 18:14:15 2014 -0700
@@ -14,9 +14,17 @@
 # to compare performance.
 
 import sys
-from subprocess import check_call, check_output
+from subprocess import check_call, check_output, CalledProcessError
+
 
-HG="hg update --quiet --check"
+def update(rev):
+    """update the repo to a revision"""
+    try:
+        check_call(['hg', 'update', '--quiet', '--check', str(rev)])
+    except CalledProcessError, exc:
+        print >> sys.stderr, 'update to revision %s failed, aborting' % rev
+        sys.exit(exc.returncode)
+
 PERF="./hg --config extensions.perf=contrib/perf.py perfrevset"
 
 target_rev = sys.argv[1]
@@ -49,7 +57,7 @@
     check_call('hg log -r %s --template "{desc|firstline}\n"' % r, shell=True)
 
     print "----------------------------"
-    check_call(HG + ' ' + r, shell=True)
+    update(r)
     for idx, rset in enumerate(revsets):
         sys.stdout.write("%i) " % idx)
         sys.stdout.flush()