]> Pileus Git - ~andy/git/commitdiff
remote-hg: fix for older versions of python
authorFelipe Contreras <felipe.contreras@gmail.com>
Wed, 28 Nov 2012 01:01:33 +0000 (02:01 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Nov 2012 02:04:00 +0000 (18:04 -0800)
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>
contrib/remote-helpers/git-remote-hg

index 62c39db5b40c43b1098eb55eb689a4fb8b981f38..016cdadb4d8d5af3b0b68c21c1df3054dd1c5f17 100755 (executable)
@@ -56,6 +56,12 @@ def hgmode(mode):
     m = { '0100755': 'x', '0120000': 'l' }
     return m.get(mode, '')
 
+def get_config(config):
+    cmd = ['git', 'config', '--get', config]
+    process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+    output, _ = process.communicate()
+    return output
+
 class Marks:
 
     def __init__(self, path):
@@ -727,12 +733,10 @@ def main(args):
     hg_git_compat = False
     track_branches = True
     try:
-        cmd = ['git', 'config', '--get', 'remote-hg.hg-git-compat']
-        if subprocess.check_output(cmd) == 'true\n':
+        if get_config('remote-hg.hg-git-compat') == 'true\n':
             hg_git_compat = True
             track_branches = False
-        cmd = ['git', 'config', '--get', 'remote-hg.track-branches']
-        if subprocess.check_output(cmd) == 'false\n':
+        if get_config('remote-hg.track-branches') == 'false\n':
             track_branches = False
     except subprocess.CalledProcessError:
         pass