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>
This commit is contained in:

committed by
Junio C Hamano

parent
25027b983e
commit
f04f489f6b
@ -685,6 +685,8 @@ def parse_tag(parser):
|
|||||||
def do_export(parser):
|
def do_export(parser):
|
||||||
global parsed_refs, bmarks, peer
|
global parsed_refs, bmarks, peer
|
||||||
|
|
||||||
|
p_bmarks = []
|
||||||
|
|
||||||
parser.next()
|
parser.next()
|
||||||
|
|
||||||
for line in parser.each_block('done'):
|
for line in parser.each_block('done'):
|
||||||
@ -706,20 +708,9 @@ def do_export(parser):
|
|||||||
pass
|
pass
|
||||||
elif ref.startswith('refs/heads/'):
|
elif ref.startswith('refs/heads/'):
|
||||||
bmark = ref[len('refs/heads/'):]
|
bmark = ref[len('refs/heads/'):]
|
||||||
if bmark in bmarks:
|
p_bmarks.append((bmark, node))
|
||||||
old = bmarks[bmark].hex()
|
# handle below
|
||||||
else:
|
continue
|
||||||
old = ''
|
|
||||||
|
|
||||||
if bmark == 'master' and 'master' not in parser.repo._bookmarks:
|
|
||||||
# fake bookmark
|
|
||||||
print "ok %s" % ref
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not bookmarks.pushbookmark(parser.repo, bmark, old, node):
|
|
||||||
print "error %s" % ref
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif ref.startswith('refs/tags/'):
|
elif ref.startswith('refs/tags/'):
|
||||||
tag = ref[len('refs/tags/'):]
|
tag = ref[len('refs/tags/'):]
|
||||||
parser.repo.tag([tag], node, None, True, None, {})
|
parser.repo.tag([tag], node, None, True, None, {})
|
||||||
@ -731,6 +722,26 @@ def do_export(parser):
|
|||||||
if peer:
|
if peer:
|
||||||
parser.repo.push(peer, force=False)
|
parser.repo.push(peer, force=False)
|
||||||
|
|
||||||
|
# handle bookmarks
|
||||||
|
for bmark, node in p_bmarks:
|
||||||
|
ref = 'refs/heads/' + bmark
|
||||||
|
|
||||||
|
if bmark in bmarks:
|
||||||
|
old = bmarks[bmark].hex()
|
||||||
|
else:
|
||||||
|
old = ''
|
||||||
|
|
||||||
|
if bmark == 'master' and 'master' not in parser.repo._bookmarks:
|
||||||
|
# fake bookmark
|
||||||
|
print "ok %s" % ref
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not bookmarks.pushbookmark(parser.repo, bmark, old, node):
|
||||||
|
print "error %s" % ref
|
||||||
|
continue
|
||||||
|
|
||||||
|
print "ok %s" % ref
|
||||||
|
|
||||||
print
|
print
|
||||||
|
|
||||||
def fix_path(alias, repo, orig_url):
|
def fix_path(alias, repo, orig_url):
|
||||||
|
Reference in New Issue
Block a user