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

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Wed Mar 26 21:49:05 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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

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 "----------------------------"


More information about the Mercurial-devel mailing list