remote-hg: split bookmark handling
Will be useful for remote bookmarks. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 11, 2013 at 07:23 UTC
f04f489f6b91213a1a6c4f7e88c8c83d43a68eeb
1 file changed
+25
-14
contrib/remote-helpers/git-remote-hg
+25
-14
@@ -685,6 +685,8 @@ def parse_tag(parser):
685
def do_export(parser):
686
global parsed_refs, bmarks, peer
687
688
+ p_bmarks = []
689
+
690
parser.next()
691
692
for line in parser.each_block('done'):
@@ -706,20 +708,9 @@ def do_export(parser):
708
pass
709
elif ref.startswith('refs/heads/'):
710
bmark = ref[len('refs/heads/'):]
709
- if bmark in bmarks:
710
- old = bmarks[bmark].hex()
711
- else:
712
- old = ''
713
-
714
- if bmark == 'master' and 'master' not in parser.repo._bookmarks:
715
- # fake bookmark
716
- print "ok %s" % ref
717
- continue
718
-
719
- if not bookmarks.pushbookmark(parser.repo, bmark, old, node):
720
- print "error %s" % ref
721
- continue
722
-
711
+ p_bmarks.append((bmark, node))
712
+ # handle below
713
+ continue
714
elif ref.startswith('refs/tags/'):
715
tag = ref[len('refs/tags/'):]
716
parser.repo.tag([tag], node, None, True, None, {})
@@ -731,6 +722,26 @@ def do_export(parser):
722
if peer:
723
parser.repo.push(peer, force=False)
724
725
+ # handle bookmarks
726
+ for bmark, node in p_bmarks:
727
+ ref = 'refs/heads/' + bmark
728
+
729
+ if bmark in bmarks:
730
+ old = bmarks[bmark].hex()
731
+ else:
732
+ old = ''
733
+
734
+ if bmark == 'master' and 'master' not in parser.repo._bookmarks:
735
+ # fake bookmark
736
+ print "ok %s" % ref
737
+ continue
738
+
739
+ if not bookmarks.pushbookmark(parser.repo, bmark, old, node):
740
+ print "error %s" % ref
741
+ continue
742
+
743
+ print "ok %s" % ref
744
+
745
print
746
747
def fix_path(alias, repo, orig_url):