From 4b31e5a4d050e4d6b8fd0eab4333c475ad29324c Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 7 Apr 2012 00:27:45 -0500 Subject: [PATCH] remote-hg: another case of Postel's law This change allows invalid input from Mercurial repositories where the author is recorded as 'Name '). With this change, importing http://scelenic.com/hg itself no longer fails with: fatal: Missing > in ident string: Benoit Boissinot 1129685868 -0700 Signed-off-by: Johannes Schindelin --- git_remote_helpers/hg/hg.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/git_remote_helpers/hg/hg.py b/git_remote_helpers/hg/hg.py index dd5756d4bb..cdd13fa513 100644 --- a/git_remote_helpers/hg/hg.py +++ b/git_remote_helpers/hg/hg.py @@ -76,17 +76,21 @@ class GitHg(object): author = ctx.user() # check for git author pattern compliance - regex = re.compile('^(.*?) ?\<(.*?)\>(.*)$') + regex = re.compile('^(.*?) ?\<(.*?)(|\>(.*))$') a = regex.match(author) if a: name = a.group(1) email = a.group(2) - if len(a.group(3)) > 0: - name += ' ext:(' + urllib.quote(a.group(3)) + ')' + extra = a.group(4) + if not extra is None and len(extra) > 0: + name += ' ext:(' + urllib.quote(extra) + ')' author = name + ' <' + email + '>' else: - author = author + ' ' + if author.find('<') >= 0: + author = author + '>' + else: + author = author + ' ' if 'author' in ctx.extra(): author = apply_delta(author, ctx.extra()['author']) -- 2.11.4.GIT