Mercurial > hg > hg-git
diff hggit/git_handler.py @ 602:65d8a43bc5ee
git_handler: skip exporting hg tags whose names are not valid as git tag name
author | nsuke <nsukeg@gmail.com> |
---|---|
date | Mon, 12 Aug 2013 23:20:41 +0900 (2013-08-12) |
parents | d6b9c30a3e0f |
children | 6da65b534370 |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -4,7 +4,7 @@ from dulwich.errors import HangupException, GitProtocolError, UpdateRefsError from dulwich.objects import Blob, Commit, Tag, Tree, parse_timezone, S_IFGITLINK from dulwich.pack import create_delta, apply_delta -from dulwich.repo import Repo +from dulwich.repo import Repo, check_ref_format from dulwich import client from dulwich import config as dul_config @@ -1039,12 +1039,18 @@ tag = tag.replace(' ', '_') target = self.map_git_get(hex(sha)) if target is not None: - self.git.refs['refs/tags/' + tag] = target - self.tags[tag] = hex(sha) + tag_refname = 'refs/tags/' + tag + if(check_ref_format(tag_refname)): + self.git.refs[tag_refname] = target + self.tags[tag] = hex(sha) + else: + self.repo.ui.warn( + 'Skipping export of tag %s because it ' + 'has invalid name as a git refname.\n' % tag) else: self.repo.ui.warn( 'Skipping export of tag %s because it ' - 'has no matching git revision.' % tag) + 'has no matching git revision.\n' % tag) def _filter_for_bookmarks(self, bms): if not self.branch_bookmark_suffix: