Merge branch 'maint'
[gitweb.git] / contrib / remote-helpers / git-remote-hg
index bf5e5b473d39f95d0cfb7a42aacdcd2761d59734..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):
@@ -439,6 +445,8 @@ def list_head(repo, cur):
         # fake bookmark from current branch
         head = cur
         node = repo['.']
+        if not node:
+            node = repo['tip']
         if not node:
             return
         if head == 'default':
@@ -563,7 +571,7 @@ def parse_commit(parser):
 
     for line in parser:
         if parser.check('M'):
-            t, m, mark_ref, path = line.split(' ')
+            t, m, mark_ref, path = line.split(' ', 3)
             mark = int(mark_ref[1:])
             f = { 'mode' : hgmode(m), 'data' : blob_marks[mark] }
         elif parser.check('D'):
@@ -702,6 +710,9 @@ def do_export(parser):
         elif ref.startswith('refs/tags/'):
             tag = ref[len('refs/tags/'):]
             parser.repo.tag([tag], node, None, True, None, {})
+        else:
+            # transport-helper/fast-export bugs
+            continue
         print "ok %s" % ref
 
     print
@@ -722,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