remote-hg: allow refs with spaces
Mercurial supports them, Git doesn't. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
7c0580586f
commit
b0f6c5835d
@ -75,6 +75,12 @@ def hgmode(mode):
|
|||||||
def hghex(node):
|
def hghex(node):
|
||||||
return hg.node.hex(node)
|
return hg.node.hex(node)
|
||||||
|
|
||||||
|
def hgref(ref):
|
||||||
|
return ref.replace('___', ' ')
|
||||||
|
|
||||||
|
def gitref(ref):
|
||||||
|
return ref.replace(' ', '___')
|
||||||
|
|
||||||
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)
|
||||||
@ -437,10 +443,10 @@ def export_ref(repo, name, kind, head):
|
|||||||
marks.set_tip(ename, rev)
|
marks.set_tip(ename, rev)
|
||||||
|
|
||||||
def export_tag(repo, tag):
|
def export_tag(repo, tag):
|
||||||
export_ref(repo, tag, 'tags', repo[tag])
|
export_ref(repo, tag, 'tags', repo[hgref(tag)])
|
||||||
|
|
||||||
def export_bookmark(repo, bmark):
|
def export_bookmark(repo, bmark):
|
||||||
head = bmarks[bmark]
|
head = bmarks[hgref(bmark)]
|
||||||
export_ref(repo, bmark, 'bookmarks', head)
|
export_ref(repo, bmark, 'bookmarks', head)
|
||||||
|
|
||||||
def export_branch(repo, branch):
|
def export_branch(repo, branch):
|
||||||
@ -479,14 +485,14 @@ def branch_tip(repo, branch):
|
|||||||
def get_branch_tip(repo, branch):
|
def get_branch_tip(repo, branch):
|
||||||
global branches
|
global branches
|
||||||
|
|
||||||
heads = branches.get(branch, None)
|
heads = branches.get(hgref(branch), None)
|
||||||
if not heads:
|
if not heads:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# verify there's only one head
|
# verify there's only one head
|
||||||
if (len(heads) > 1):
|
if (len(heads) > 1):
|
||||||
warn("Branch '%s' has more than one head, consider merging" % branch)
|
warn("Branch '%s' has more than one head, consider merging" % branch)
|
||||||
return branch_tip(repo, branch)
|
return branch_tip(repo, hgref(branch))
|
||||||
|
|
||||||
return heads[0]
|
return heads[0]
|
||||||
|
|
||||||
@ -508,6 +514,7 @@ def list_head(repo, cur):
|
|||||||
head = 'master'
|
head = 'master'
|
||||||
bmarks[head] = node
|
bmarks[head] = node
|
||||||
|
|
||||||
|
head = gitref(head)
|
||||||
print "@refs/heads/%s HEAD" % head
|
print "@refs/heads/%s HEAD" % head
|
||||||
g_head = (head, node)
|
g_head = (head, node)
|
||||||
|
|
||||||
@ -529,15 +536,15 @@ def do_list(parser):
|
|||||||
branches[branch] = heads
|
branches[branch] = heads
|
||||||
|
|
||||||
for branch in branches:
|
for branch in branches:
|
||||||
print "? refs/heads/branches/%s" % branch
|
print "? refs/heads/branches/%s" % gitref(branch)
|
||||||
|
|
||||||
for bmark in bmarks:
|
for bmark in bmarks:
|
||||||
print "? refs/heads/%s" % bmark
|
print "? refs/heads/%s" % gitref(bmark)
|
||||||
|
|
||||||
for tag, node in repo.tagslist():
|
for tag, node in repo.tagslist():
|
||||||
if tag == 'tip':
|
if tag == 'tip':
|
||||||
continue
|
continue
|
||||||
print "? refs/tags/%s" % tag
|
print "? refs/tags/%s" % gitref(tag)
|
||||||
|
|
||||||
print
|
print
|
||||||
|
|
||||||
@ -674,7 +681,8 @@ def parse_commit(parser):
|
|||||||
|
|
||||||
# Check if the ref is supposed to be a named branch
|
# Check if the ref is supposed to be a named branch
|
||||||
if ref.startswith('refs/heads/branches/'):
|
if ref.startswith('refs/heads/branches/'):
|
||||||
extra['branch'] = ref[len('refs/heads/branches/'):]
|
branch = ref[len('refs/heads/branches/'):]
|
||||||
|
extra['branch'] = hgref(branch)
|
||||||
|
|
||||||
if mode == 'hg':
|
if mode == 'hg':
|
||||||
i = data.find('\n--HG--\n')
|
i = data.find('\n--HG--\n')
|
||||||
@ -803,6 +811,7 @@ def do_export(parser):
|
|||||||
continue
|
continue
|
||||||
elif ref.startswith('refs/tags/'):
|
elif ref.startswith('refs/tags/'):
|
||||||
tag = ref[len('refs/tags/'):]
|
tag = ref[len('refs/tags/'):]
|
||||||
|
tag = hgref(tag)
|
||||||
author, msg = parsed_tags.get(tag, (None, None))
|
author, msg = parsed_tags.get(tag, (None, None))
|
||||||
if mode == 'git':
|
if mode == 'git':
|
||||||
if not msg:
|
if not msg:
|
||||||
|
Loading…
Reference in New Issue
Block a user