From 79cb664c696a3712c06bb0dd275ed0c3fe2f52ff Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 28 Jun 2016 18:42:32 -0700 Subject: [PATCH] hg2git.py: do not require python 2.7 The subprocess.check_output call is a version 2.7 or later only thingy. Replace it with something that's more compatible but still avoids using os.popen. Signed-off-by: Kyle J. McKay --- hg2git.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hg2git.py b/hg2git.py index ea10d4f..bfce8c9 100755 --- a/hg2git.py +++ b/hg2git.py @@ -7,7 +7,7 @@ from mercurial import hg,ui import re import os import sys -import subprocess +from subprocess import PIPE,Popen # default git branch name cfg_master='master' @@ -161,9 +161,10 @@ def get_git_sha1(name,type='heads'): try: # use git-rev-parse to support packed refs ref="refs/%s/%s" % (type,name) - l=subprocess.check_output(["git", "rev-parse", "--verify", "--quiet", ref]) + proc = Popen(["git", "rev-parse", "--verify", "--quiet", ref], stdout=PIPE) + l = proc.communicate()[0] if l == None or len(l) == 0: return None return l[0:40] - except subprocess.CalledProcessError: + except: return None -- 2.11.4.GIT