Patchwork [1,of,3] revsetbenchmark: remove python 2.7 dependency

login
register
mail settings
Submitter Durham Goode
Date April 1, 2014, 2:49 a.m.
Message ID <ab02d288a5968b12c2d5.1396320590@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/4176/
State Accepted
Commit b5de9dde181c2edd30f290713c2db0a289e9f13f
Headers show

Comments

Durham Goode - April 1, 2014, 2:49 a.m.
# HG changeset patch
# User Durham Goode <durham@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.

Patch

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