changeset 540:3fb942852b1c

Precompile Git author extra data regular expression
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 21 Sep 2012 19:39:53 -0700
parents 7bf60690386c
children df1598b722e8
files hggit/git_handler.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py	Fri Sep 21 19:36:57 2012 -0700
+++ b/hggit/git_handler.py	Fri Sep 21 19:39:53 2012 -0700
@@ -33,6 +33,8 @@
 
 RE_GIT_SANITIZE_AUTHOR = re.compile('[<>\n]')
 
+RE_GIT_AUTHOR_EXTRA = re.compile('^(.*?)\ ext:\((.*)\) <(.*)\>$')
+
 # Test for git:// and git+ssh:// URI.
 # Support several URL forms, including separating the
 # host and path with either a / or : (sepr)
@@ -707,8 +709,7 @@
 
         # convert extra data back to the end
         if ' ext:' in commit.author:
-            regex = re.compile('^(.*?)\ ext:\((.*)\) <(.*)\>$')
-            m = regex.match(commit.author)
+            m = RE_GIT_AUTHOR_EXTRA.match(commit.author)
             if m:
                 name = m.group(1)
                 ex = urllib.unquote(m.group(2))