Patchwork [6,of,9] revsetbenchmark: convert revision display to proper subprocesscall

login
register
mail settings
Submitter Pierre-Yves David
Date March 27, 2014, 2:49 a.m.
Message ID <88331f2ede08e631c392.1395888547@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4085/
State Accepted
Commit b2353501d6dc02a7246b493585d95ded922f0b5c
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 1395883637 25200
#      Wed Mar 26 18:27:17 2014 -0700
# Node ID 88331f2ede08e631c3926d58375a1b84021ca16e
# Parent  08e5abec5ea0d3e090880a62e577255972cc0cfd
revsetbenchmark: convert revision display to proper subprocesscall

Patch

diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py
+++ b/contrib/revsetbenchmarks.py
@@ -32,10 +32,17 @@  def perf(revset):
                     'perfrevset', revset])
     except CalledProcessError, exc:
         print >> sys.stderr, 'abort: cannot run revset benchmark'
         sys.exit(exc.returncode)
 
+def printrevision(rev):
+    """print data about a revision"""
+    sys.stdout.write("Revision: ")
+    sys.stdout.flush()
+    check_call(['hg', 'log', '--rev', str(rev), '--template',
+               '{desc|firstline}\n'])
+
 
 target_rev = sys.argv[1]
 
 revsetsfile = sys.stdin
 if len(sys.argv) > 2:
@@ -58,14 +65,11 @@  revs = check_output("hg log --template='
 revs = [r for r in revs.split() if r]
 
 # Benchmark revisions
 for r in revs:
     print "----------------------------"
-    sys.stdout.write("Revision: ")
-    sys.stdout.flush()
-    check_call('hg log -r %s --template "{desc|firstline}\n"' % r, shell=True)
-
+    printrevision(r)
     print "----------------------------"
     update(r)
     for idx, rset in enumerate(revsets):
         sys.stdout.write("%i) " % idx)
         sys.stdout.flush()