[PATCH 2 of 2] templatefilters: improve person() for john.doe at example.com

Adrian Buehlmann adrian at cadifra.com
Sun Apr 17 15:32:35 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1303070736 -7200
# Node ID ec4f696d1d0a3e1adce24b0030a77c282d26350f
# Parent  989a7f3abceb143a547f17e7520863d8124052f1
templatefilters: improve person() for john.doe at example.com

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -245,14 +245,15 @@
     >>> person('John Doe <john at example.com>')
     'John Doe'
     >>> person('john.doe at example.com')
-    'john'
+    'john doe'
     """
     if not '@' in author:
         return author
     f = author.find('<')
-    if f == -1:
-        return util.shortuser(author)
-    return author[:f].rstrip()
+    if f != -1:
+        return author[:f].rstrip()
+    f = author.find('@')
+    return author[:f].replace('.', ' ')
 
 def rfc3339date(text):
     """:rfc3339date: Date. Returns a date using the Internet date format


More information about the Mercurial-devel mailing list