contrib/revsetbenchmarks.py
changeset 25528 a6bcd70cd9c2
parent 23139 e53f6b72a0e4
child 25529 3e80691d0dfe
--- a/contrib/revsetbenchmarks.py	Wed Jun 10 19:26:16 2015 -0700
+++ b/contrib/revsetbenchmarks.py	Tue Jun 09 15:49:14 2015 -0700
@@ -36,19 +36,24 @@
         print >> sys.stderr, 'update to revision %s failed, aborting' % rev
         sys.exit(exc.returncode)
 
+
+def hg(cmd, repo=None):
+    """run a mercurial command
+
+    <cmd> is the list of command + argument,
+    <repo> is an optional repository path to run this command in."""
+    fullcmd = ['./hg']
+    if repo is not None:
+        fullcmd += ['-R', repo]
+    fullcmd += ['--config',
+                'extensions.perf=' + os.path.join(contribdir, 'perf.py')]
+    fullcmd += cmd
+    return check_output(fullcmd, stderr=STDOUT)
+
 def perf(revset, target=None):
     """run benchmark for this very revset"""
     try:
-        cmd = ['./hg',
-               '--config',
-               'extensions.perf='
-               + os.path.join(contribdir, 'perf.py'),
-               'perfrevset',
-               revset]
-        if target is not None:
-            cmd.append('-R')
-            cmd.append(target)
-        output = check_output(cmd, stderr=STDOUT)
+        output = hg(['perfrevset', revset], repo=target)
         output = output.lstrip('!') # remove useless ! in this context
         return output.strip()
     except CalledProcessError, exc: