Sebastian Schmidt
unread,May 27, 2012, 9:46:40 AM5/27/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to hg-...@googlegroups.com
Besides replacing a space to an underscore when converting hg tags
to git also deal with a colon the same way.
---
hggit/git_handler.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 98fc96e..0b71a61 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -1,4 +1,4 @@
-import os, math, urllib, re
+import os, math, urllib, re, string
from dulwich.errors import HangupException, GitProtocolError
from dulwich.index import commit_tree
@@ -767,6 +767,9 @@ class GitHandler(object):
except (HangupException, GitProtocolError), e:
raise hgutil.Abort(_("git remote error: ") + str(e))
+ def sanitize_ref(self, ref):
+ return ref.translate(string.maketrans(" :", "__"))
+
def get_changed_refs(self, refs, revs, force):
new_refs = refs.copy()
@@ -791,7 +794,7 @@ class GitHandler(object):
]
else:
labels = lambda c: ctx.tags()
- prep = lambda itr: [i.replace(' ', '_') for i in itr]
+ prep = lambda itr: [self.sanitize_ref(i) for i in itr]
heads = [t for t in prep(labels(ctx)) if t in self.local_heads()]
tags = [t for t in prep(labels(ctx)) if t in self.tags]
@@ -902,7 +905,7 @@ class GitHandler(object):
def export_hg_tags(self):
for tag, sha in self.repo.tags().iteritems():
if self.repo.tagtype(tag) in ('global', 'git'):
- tag = tag.replace(' ', '_')
+ tag = self.sanitize_ref(tag)
self.git.refs['refs/tags/' + tag] = self.map_git_get(hex(sha))
self.tags[tag] = hex(sha)
--
1.7.10