Patchwork [4,of,9] revsetbenchmark: convert update to proper subprocess call

login
register
mail settings
Submitter Pierre-Yves David
Date March 27, 2014, 2:49 a.m.
Message ID <a9b35a2e2cb09bdb1e50.1395888545@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4083/
State Accepted
Commit d0c2535c7aba2d6c196f0d47a42874cc59f10ab9
Headers show

Comments

Pierre-Yves David - March 27, 2014, 2:49 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1395882855 25200
#      Wed Mar 26 18:14:15 2014 -0700
# Node ID a9b35a2e2cb09bdb1e504ab7aab0ae4718723d4a
# Parent  9df1c226d1cd2aca826dbea8c3fcd80cb2f20d19
revsetbenchmark: convert update to proper subprocess call

Patch

diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py
+++ b/contrib/revsetbenchmarks.py
@@ -12,13 +12,21 @@ 
 #
 # This script also does one run of the current version of mercurial installed
 # 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]
 
 revsetsfile = sys.stdin
@@ -47,11 +55,11 @@  for r in revs:
     sys.stdout.write("Revision: ")
     sys.stdout.flush()
     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()
         check_call(PERF + ' "%s"' % rset, shell=True)
     print "----------------------------"