git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Nov 28, 2012, 01:01 UTC
Message-ID
<1354064495-23171-3-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1354064495-23171-1-git-send-email-felipe.contreras@gmail.com>

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>
---
 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
Previous: Felipe ContrerasNext: Felipe Contreras
Message 3 of 8 in “remote-helpers: general fixes”
  1. 0/4 remote-helpers: general fixesFelipe Contreras, Nov 28, 2012
  2. 1/4 remote-hg: fix for files with spacesFelipe Contreras, Nov 28, 2012
  3. 2/4 remote-hg: fix for older versions of pythonFelipe Contreras, Nov 28, 2012
  4. 3/4 remote-bzr: add support for older versions of bzrFelipe Contreras, Nov 28, 2012
  5. 4/4 remote-bzr: detect local repositoriesFelipe Contreras, Nov 28, 2012
  6. Junio C HamanoNov 28, 2012
  7. Felipe ContrerasNov 28, 2012
  8. Junio C HamanoNov 28, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.