[PATCH 2/4] remote-hg: fix for older versions of python

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 contrib/remote-helpers/git-remote-hg | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 62c39db..016cdad 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -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
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]