[PATCH 1 of 3] revsetbenchmark: remove python 2.7 dependency

Durham Goode durham at fb.com
Mon Mar 31 21:49:50 CDT 2014


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1396308579 25200
#      Mon Mar 31 16:29:39 2014 -0700
# Node ID ab02d288a5968b12c2d56bc4d93291a6edf2af82
# Parent  8a6a86c9a5b58ccc020de1ff0429e72dfa5599fc
revsetbenchmark: remove python 2.7 dependency

revsetbenchmark.py used check_output which only exists in python 2.7. This
fixes it.

diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py
+++ b/contrib/revsetbenchmarks.py
@@ -14,8 +14,16 @@
 # to compare performance.
 
 import sys
-from subprocess import check_call, check_output, CalledProcessError, STDOUT
+from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE
 
+def check_output(*args, **kwargs):
+    kwargs.setdefault('stderr', PIPE)
+    kwargs.setdefault('stdout', PIPE)
+    proc = Popen(*args, **kwargs)
+    output, error = proc.communicate()
+    if proc.returncode != 0:
+        raise CalledProcessError(proc.returncode, ' '.join(args))
+    return output
 
 def update(rev):
     """update the repo to a revision"""


More information about the Mercurial-devel mailing list