Skip to content

Commit 1e31055

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 418673c commit 1e31055

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def hgmode(mode):
5656
m = { '0100755': 'x', '0120000': 'l' }
5757
return m.get(mode, '')
5858

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+
5965
class Marks:
6066

6167
def __init__(self, path):
@@ -727,12 +733,10 @@ def main(args):
727733
hg_git_compat = False
728734
track_branches = True
729735
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':
732737
hg_git_compat = True
733738
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':
736740
track_branches = False
737741
except subprocess.CalledProcessError:
738742
pass

0 commit comments

Comments
 (0)