Mercurial > hg
changeset 5975:75d9fe70c654
templater: move email function to util
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 31 Jan 2008 14:44:19 -0600 |
parents | bed929082b58 |
children | 9f1e6ab76069 |
files | contrib/churn.py hgext/bugzilla.py hgext/notify.py mercurial/mail.py mercurial/templater.py mercurial/util.py |
diffstat | 6 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/churn.py Thu Jan 31 14:44:19 2008 -0600 +++ b/contrib/churn.py Thu Jan 31 14:44:19 2008 -0600 @@ -69,7 +69,7 @@ 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])
--- a/hgext/bugzilla.py Thu Jan 31 14:44:19 2008 -0600 +++ b/hgext/bugzilla.py Thu Jan 31 14:44:19 2008 -0600 @@ -282,7 +282,7 @@ 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
--- a/hgext/notify.py Thu Jan 31 14:44:19 2008 -0600 +++ b/hgext/notify.py Thu Jan 31 14:44:19 2008 -0600 @@ -135,7 +135,7 @@ 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 @@ 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):
--- a/mercurial/mail.py Thu Jan 31 14:44:19 2008 -0600 +++ b/mercurial/mail.py Thu Jan 31 14:44:19 2008 -0600 @@ -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 _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)
--- a/mercurial/templater.py Thu Jan 31 14:44:19 2008 -0600 +++ b/mercurial/templater.py Thu Jan 31 14:44:19 2008 -0600 @@ -214,12 +214,6 @@ 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 @@ "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),
--- a/mercurial/util.py Thu Jan 31 14:44:19 2008 -0600 +++ b/mercurial/util.py Thu Jan 31 14:44:19 2008 -0600 @@ -1636,6 +1636,12 @@ 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: