summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Clatworthy <ian.clatworthy@internode.on.net>2009-04-08 12:33:08 +1000
committerIan Clatworthy <ian.clatworthy@internode.on.net>2009-04-08 12:33:08 +1000
commita1a067c65c5d3927a33b1d3864741d52e4e3635b (patch)
treedf9ae08d97767aaa66bc99026b55a121ef609611
parentb5651405af553e4d8ebf94c8361c50fa4d56ac8b (diff)
downloadbzr-fastimport-a1a067c65c5d3927a33b1d3864741d52e4e3635b.tar.gz
fix round-tripping of committer & author when name is an email
-rw-r--r--bzr_commit_handler.py13
-rwxr-xr-xbzr_exporter.py9
2 files changed, 18 insertions, 4 deletions
diff --git a/bzr_commit_handler.py b/bzr_commit_handler.py
index f26891f..a71a12c 100644
--- a/bzr_commit_handler.py
+++ b/bzr_commit_handler.py
@@ -165,6 +165,13 @@ class GenericCommitHandler(processor.CommitHandler):
"""Get a Bazaar file identifier for a path."""
return self.bzr_file_id_and_new(path)[0]
+ def _format_name_email(self, name, email):
+ """Format name & email as a string."""
+ if email:
+ return "%s <%s>" % (name, email)
+ else:
+ return name
+
def gen_revision_id(self):
"""Generate a revision id.
@@ -173,17 +180,17 @@ class GenericCommitHandler(processor.CommitHandler):
committer = self.command.committer
# Perhaps 'who' being the person running the import is ok? If so,
# it might be a bit quicker and give slightly better compression?
- who = "%s <%s>" % (committer[0],committer[1])
+ who = self._format_name_email(committer[0], committer[1])
timestamp = committer[2]
return generate_ids.gen_revision_id(who, timestamp)
def build_revision(self):
rev_props = {}
committer = self.command.committer
- who = "%s <%s>" % (committer[0],committer[1])
+ who = self._format_name_email(committer[0], committer[1])
author = self.command.author
if author is not None:
- author_id = "%s <%s>" % (author[0],author[1])
+ author_id = self._format_name_email(author[0], author[1])
if author_id != who:
rev_props['author'] = author_id
return revision.Revision(
diff --git a/bzr_exporter.py b/bzr_exporter.py
index 3ffe56a..3e0811a 100755
--- a/bzr_exporter.py
+++ b/bzr_exporter.py
@@ -260,7 +260,14 @@ class BzrFastExporter(object):
def _get_commit_command(self, git_ref, mark, revobj, file_cmds):
# Get the committer and author info
committer = revobj.committer
- name, email = parseaddr(committer)
+ if committer.find('<') == -1:
+ # If the email isn't inside <>, we need to use it as the name
+ # in order for things to round-trip correctly.
+ # (note: parseaddr('a@b.com') => name:'', email: 'a@b.com')
+ name = committer
+ email = ''
+ else:
+ name, email = parseaddr(committer)
committer_info = (name, email, revobj.timestamp, revobj.timezone)
if self._multi_author_api_available:
author = revobj.get_apparent_authors()[0]