# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 2008-01-31 20:44:19
# Node ID 75d9fe70c65457647423b37fdcc91f26b33ed037
# Parent  bed929082b587d83c68a9b668376ec1677ff87c9

templater: move email function to util

diff --git a/contrib/churn.py b/contrib/churn.py
--- a/contrib/churn.py
+++ b/contrib/churn.py
@@ -69,7 +69,7 @@ def __gather(ui, repo, node1, node2):
     modified, added, removed, deleted, unknown = changes
 
     who = repo.changelog.read(node2)[1]
-    who = templater.email(who) # get the email of the person
+    who = util.email(who) # get the email of the person
 
     mmap1 = repo.manifest.read(repo.changelog.read(node1)[0])
     mmap2 = repo.manifest.read(repo.changelog.read(node2)[0])
diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
--- a/hgext/bugzilla.py
+++ b/hgext/bugzilla.py
@@ -282,7 +282,7 @@ class bugzilla(object):
                root=self.repo.root,
                webroot=webroot(self.repo.root))
         data = self.ui.popbuffer()
-        self.add_comment(bugid, data, templater.email(ctx.user()))
+        self.add_comment(bugid, data, util.email(ctx.user()))
 
 def hook(ui, repo, hooktype, node=None, **kwargs):
     '''add comment to bugzilla for each changeset that refers to a
diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -135,7 +135,7 @@ class notifier(object):
     def fixmail(self, addr):
         '''try to clean up email addresses.'''
 
-        addr = templater.email(addr.strip())
+        addr = util.email(addr.strip())
         if self.domain:
             a = addr.find('@localhost')
             if a != -1:
@@ -231,7 +231,7 @@ class notifier(object):
         else:
             self.ui.status(_('notify: sending %d subscribers %d changes\n') %
                            (len(self.subs), count))
-            mail.sendmail(self.ui, templater.email(msg['From']),
+            mail.sendmail(self.ui, util.email(msg['From']),
                           self.subs, msgtext)
 
     def diff(self, node, ref):
diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -6,7 +6,7 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 from i18n import _
-import os, smtplib, templater, util, socket
+import os, smtplib, util, socket
 
 def _smtp(ui):
     '''build an smtp connection and return a function to send mail'''
@@ -50,8 +50,8 @@ def _smtp(ui):
 def _sendmail(ui, sender, recipients, msg):
     '''send mail using sendmail.'''
     program = ui.config('email', 'method')
-    cmdline = '%s -f %s %s' % (program, templater.email(sender),
-                               ' '.join(map(templater.email, recipients)))
+    cmdline = '%s -f %s %s' % (program, util.email(sender),
+                               ' '.join(map(util.email, recipients)))
     ui.note(_('sending mail: %s\n') % cmdline)
     fp = os.popen(cmdline, 'w')
     fp.write(msg)
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -214,12 +214,6 @@ def domain(author):
     if f >= 0: author = author[:f]
     return author
 
-def email(author):
-    '''get email of author.'''
-    r = author.find('>')
-    if r == -1: r = None
-    return author[author.find('<')+1:r]
-
 def person(author):
     '''get name of author, or else username.'''
     f = author.find('<')
@@ -257,7 +251,7 @@ common_filters = {
     "age": age,
     "date": lambda x: util.datestr(x),
     "domain": domain,
-    "email": email,
+    "email": util.email,
     "escape": lambda x: cgi.escape(x, True),
     "fill68": lambda x: fill(x, width=68),
     "fill76": lambda x: fill(x, width=76),
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1636,6 +1636,12 @@ def shortuser(user):
         user = user[:f]
     return user
 
+def email(author):
+    '''get email of author.'''
+    r = author.find('>')
+    if r == -1: r = None
+    return author[author.find('<')+1:r]
+
 def ellipsis(text, maxlength=400):
     """Trim string to at most maxlength (default: 400) characters."""
     if len(text) <= maxlength: