diff options
Diffstat (limited to 'exporter.py')
-rw-r--r-- | exporter.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/exporter.py b/exporter.py index e67a621..fd1de00 100644 --- a/exporter.py +++ b/exporter.py @@ -152,13 +152,17 @@ class BzrFastExporter(object): def __init__(self, source, destination, git_branch=None, checkpoint=-1, import_marks_file=None, export_marks_file=None, revision=None, - verbose=False, plain_format=False): + verbose=False, plain_format=False, rewrite_tags=False): """Export branch data in fast import format. :param plain_format: if True, 'classic' fast-import format is used without any extended features; if False, the generated data is richer and includes information like multiple authors, revision properties, etc. + + :param rewrite_tags: if True tag names will be rewritten to be + git-compatible. Otherwise tags which aren't valid for git will + be skiped. """ self.source = source self.outf = _get_output_stream(destination) @@ -169,6 +173,8 @@ class BzrFastExporter(object): self.revision = revision self.excluded_revisions = set() self.plain_format = plain_format + self.rewrite_tags = rewrite_tags + self.rewrite_dict = dict() self._multi_author_api_available = hasattr(bzrlib.revision.Revision, 'get_apparent_authors') self.properties_to_exclude = ['authors', 'author'] @@ -594,9 +600,15 @@ class BzrFastExporter(object): else: git_ref = 'refs/tags/%s' % tag.encode("utf-8") if self.plain_format and not check_ref_format(git_ref): - self.warning('not creating tag %r as its name would not be ' - 'valid in git.', git_ref) - continue + if self.rewrite_tags: + new_ref = sanitize_ref_name_for_git(self.rewrite_dict, git_ref) + self.warning('tag %r is exported as %r to be valid in git.', + git_ref, new_ref) + git_ref = new_ref + else: + self.warning('not creating tag %r as its name would not be ' + 'valid in git.', git_ref) + continue self.print_cmd(commands.ResetCommand(git_ref, ":" + str(mark))) def _next_tmp_branch_name(self): |