remote-hg: fix for older versions of python

As Amit Bakshi reported, older versions of python (< 2.7) don't have subprocess.check_output, so let's use subprocess.Popen directly as suggested. Suggested-by: Amit Bakshi <ambakshi@gmail.com> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Nov 28, 2012 at 02:01 UTC 1e310551e7e3a2efe41cbe1bc0a6b919cd6f7d34
1 file changed +8 -4
contrib/remote-helpers/git-remote-hg
+8 -4
@@ -56,6 +56,12 @@ def hgmode(mode):
56 m = { '0100755': 'x', '0120000': 'l' }
57 return m.get(mode, '')
58
59 +def get_config(config):
60 + cmd = ['git', 'config', '--get', config]
61 + process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
62 + output, _ = process.communicate()
63 + return output
64 +
65 class Marks:
66
67 def __init__(self, path):
@@ -727,12 +733,10 @@ def main(args):
733 hg_git_compat = False
734 track_branches = True
735 try:
730 - cmd = ['git', 'config', '--get', 'remote-hg.hg-git-compat']
731 - if subprocess.check_output(cmd) == 'true\n':
736 + if get_config('remote-hg.hg-git-compat') == 'true\n':
737 hg_git_compat = True
738 track_branches = False
734 - cmd = ['git', 'config', '--get', 'remote-hg.track-branches']
735 - if subprocess.check_output(cmd) == 'false\n':
739 + if get_config('remote-hg.track-branches') == 'false\n':
740 track_branches = False
741 except subprocess.CalledProcessError:
742 pass