From: Paul O’Shannessy Date: Tue, 18 Oct 2011 23:20:54 +0000 (-0700) Subject: Use hg methods to extract name and email when doing user fixup X-Git-Tag: v160415~52 X-Git-Url: https://repo.or.cz/w/fast-export.git/commitdiff_plain/3e00d99d39ae885c97f78a0ce116f09e2d8d221e Use hg methods to extract name and email when doing user fixup --- diff --git a/hg2git.py b/hg2git.py index baa41cd..72967d2 100755 --- a/hg2git.py +++ b/hg2git.py @@ -3,7 +3,7 @@ # Copyright (c) 2007, 2008 Rocco Rutte and others. # License: MIT -from mercurial import repo,hg,cmdutil,util,ui,revlog,node +from mercurial import repo,hg,cmdutil,util,ui,revlog,node,templatefilters import re import os import sys @@ -41,14 +41,13 @@ def fixup_user(user,authors): user=authors.get(user,user) name,mail,m='','',user_re.match(user) if m==None: - # if we don't have 'Name ' syntax, use 'user - # ' if use contains no at and - # 'user ' otherwise - name=user - if '@' not in user: - mail='' - else: - mail='<%s>' % user + # if we don't have 'Name ' syntax, extract name + # and mail from hg helpers. this seems to work pretty well. + # if email doesn't contain @, replace it with devnull@localhost + name=templatefilters.person(user) + mail='<%s>' % util.email(user) + if '@' not in mail: + mail = '' else: # if we have 'Name ' syntax, everything is fine :) name,mail=m.group(1),m.group(2)