remote-hg: refactor export
No functional changes. 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
f04f489f6b
commit
0ff1b61770
@ -9,7 +9,7 @@
|
|||||||
# Then you can clone with:
|
# Then you can clone with:
|
||||||
# git clone hg::/path/to/mercurial/repo/
|
# git clone hg::/path/to/mercurial/repo/
|
||||||
|
|
||||||
from mercurial import hg, ui, bookmarks, context, util, encoding
|
from mercurial import hg, ui, bookmarks, context, util, encoding, node
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -60,6 +60,9 @@ def hgmode(mode):
|
|||||||
m = { '100755': 'x', '120000': 'l' }
|
m = { '100755': 'x', '120000': 'l' }
|
||||||
return m.get(mode, '')
|
return m.get(mode, '')
|
||||||
|
|
||||||
|
def hghex(node):
|
||||||
|
return hg.node.hex(node)
|
||||||
|
|
||||||
def get_config(config):
|
def get_config(config):
|
||||||
cmd = ['git', 'config', '--get', config]
|
cmd = ['git', 'config', '--get', config]
|
||||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
@ -705,19 +708,18 @@ def do_export(parser):
|
|||||||
|
|
||||||
for ref, node in parsed_refs.iteritems():
|
for ref, node in parsed_refs.iteritems():
|
||||||
if ref.startswith('refs/heads/branches'):
|
if ref.startswith('refs/heads/branches'):
|
||||||
pass
|
print "ok %s" % ref
|
||||||
elif ref.startswith('refs/heads/'):
|
elif ref.startswith('refs/heads/'):
|
||||||
bmark = ref[len('refs/heads/'):]
|
bmark = ref[len('refs/heads/'):]
|
||||||
p_bmarks.append((bmark, node))
|
p_bmarks.append((bmark, node))
|
||||||
# handle below
|
|
||||||
continue
|
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, {})
|
||||||
|
print "ok %s" % ref
|
||||||
else:
|
else:
|
||||||
# transport-helper/fast-export bugs
|
# transport-helper/fast-export bugs
|
||||||
continue
|
continue
|
||||||
print "ok %s" % ref
|
|
||||||
|
|
||||||
if peer:
|
if peer:
|
||||||
parser.repo.push(peer, force=False)
|
parser.repo.push(peer, force=False)
|
||||||
@ -725,6 +727,7 @@ def do_export(parser):
|
|||||||
# handle bookmarks
|
# handle bookmarks
|
||||||
for bmark, node in p_bmarks:
|
for bmark, node in p_bmarks:
|
||||||
ref = 'refs/heads/' + bmark
|
ref = 'refs/heads/' + bmark
|
||||||
|
new = hghex(node)
|
||||||
|
|
||||||
if bmark in bmarks:
|
if bmark in bmarks:
|
||||||
old = bmarks[bmark].hex()
|
old = bmarks[bmark].hex()
|
||||||
@ -733,10 +736,11 @@ def do_export(parser):
|
|||||||
|
|
||||||
if bmark == 'master' and 'master' not in parser.repo._bookmarks:
|
if bmark == 'master' and 'master' not in parser.repo._bookmarks:
|
||||||
# fake bookmark
|
# fake bookmark
|
||||||
print "ok %s" % ref
|
pass
|
||||||
continue
|
elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
|
||||||
|
# updated locally
|
||||||
if not bookmarks.pushbookmark(parser.repo, bmark, old, node):
|
pass
|
||||||
|
else:
|
||||||
print "error %s" % ref
|
print "error %s" % ref
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user