At least the opensolaris hg repo has tag names containing '*',
so sanitize all branch and tag names roughly according to the
specs for git-check-ref-format(1).
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
+def sanitize_name(name,what="branch"):
+ """Sanitize input roughly according to git-check-ref-format(1)"""
+
+ def dot(name):
+ if name[0] == '.': return '_'+name[1:]
+ return name
+
+ n=name
+ p=re.compile('([[ ^:?*]|\.\.)')
+ n=p.sub('_', n)
+ if n[-1] == '/': n=n[:-1]+'_'
+ n='/'.join(map(dot,n.split('/')))
+ p=re.compile('_+')
+ n=p.sub('_', n)
+
+ if n!=name:
+ sys.stderr.write('Warning: sanitized %s [%s] to [%s]\n' % (what,name,n))
+ return n
+
def export_commit(ui,repo,revision,marks,heads,last,max,count,authors,sob):
(revnode,_,user,(time,timezone),files,desc,branch,_)=get_changeset(ui,repo,revision,authors)
parents=repo.changelog.parentrevs(revision)
def export_commit(ui,repo,revision,marks,heads,last,max,count,authors,sob):
(revnode,_,user,(time,timezone),files,desc,branch,_)=get_changeset(ui,repo,revision,authors)
parents=repo.changelog.parentrevs(revision)
+ branch=sanitize_name(branch)
+
wr('commit refs/heads/%s' % branch)
wr('mark :%d' % (revision+1))
if sob:
wr('commit refs/heads/%s' % branch)
wr('mark :%d' % (revision+1))
if sob:
def export_tags(ui,repo,marks_cache,start,end,count,authors):
l=repo.tagslist()
for tag,node in l:
def export_tags(ui,repo,marks_cache,start,end,count,authors):
l=repo.tagslist()
for tag,node in l:
+ tag=sanitize_name(tag,"tag")
# ignore latest revision
if tag=='tip': continue
rev=repo.changelog.rev(node)
# ignore latest revision
if tag=='tip': continue
rev=repo.changelog.rev(node)