diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py --- a/mercurial/utils/stringutil.py +++ b/mercurial/utils/stringutil.py @@ -286,3 +286,25 @@ If s is not a valid boolean, returns None. """ return _booleans.get(s.lower(), None) + +_correctauthorformat = remod.compile('^[^<]+\s\<[^<>]+@[^<>]+\>$') +def isauthorwellformed(author): + '''Return True if the author field is well formed + (ie "Contributor Name ") + + >>> isauthorwellformed('Good Author ') + True + >>> isauthorwellformed('Author ') + True + >>> isauthorwellformed('Bad Author') + False + >>> isauthorwellformed('Bad Author >> isauthorwellformed('Bad Author author@author.com') + False + >>> isauthorwellformed('') + False + >>> isauthorwellformed('Bad Author ') + False + ''' + return bool(_correctauthorformat.match(author))