##// END OF EJS Templates
templater: move email function to util
Matt Mackall -
r5975:75d9fe70 default
parent child Browse files
Show More
@@ -69,7 +69,7 def __gather(ui, repo, node1, node2):
69 69 modified, added, removed, deleted, unknown = changes
70 70
71 71 who = repo.changelog.read(node2)[1]
72 who = templater.email(who) # get the email of the person
72 who = util.email(who) # get the email of the person
73 73
74 74 mmap1 = repo.manifest.read(repo.changelog.read(node1)[0])
75 75 mmap2 = repo.manifest.read(repo.changelog.read(node2)[0])
@@ -282,7 +282,7 class bugzilla(object):
282 282 root=self.repo.root,
283 283 webroot=webroot(self.repo.root))
284 284 data = self.ui.popbuffer()
285 self.add_comment(bugid, data, templater.email(ctx.user()))
285 self.add_comment(bugid, data, util.email(ctx.user()))
286 286
287 287 def hook(ui, repo, hooktype, node=None, **kwargs):
288 288 '''add comment to bugzilla for each changeset that refers to a
@@ -135,7 +135,7 class notifier(object):
135 135 def fixmail(self, addr):
136 136 '''try to clean up email addresses.'''
137 137
138 addr = templater.email(addr.strip())
138 addr = util.email(addr.strip())
139 139 if self.domain:
140 140 a = addr.find('@localhost')
141 141 if a != -1:
@@ -231,7 +231,7 class notifier(object):
231 231 else:
232 232 self.ui.status(_('notify: sending %d subscribers %d changes\n') %
233 233 (len(self.subs), count))
234 mail.sendmail(self.ui, templater.email(msg['From']),
234 mail.sendmail(self.ui, util.email(msg['From']),
235 235 self.subs, msgtext)
236 236
237 237 def diff(self, node, ref):
@@ -6,7 +6,7
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 from i18n import _
9 import os, smtplib, templater, util, socket
9 import os, smtplib, util, socket
10 10
11 11 def _smtp(ui):
12 12 '''build an smtp connection and return a function to send mail'''
@@ -50,8 +50,8 def _smtp(ui):
50 50 def _sendmail(ui, sender, recipients, msg):
51 51 '''send mail using sendmail.'''
52 52 program = ui.config('email', 'method')
53 cmdline = '%s -f %s %s' % (program, templater.email(sender),
54 ' '.join(map(templater.email, recipients)))
53 cmdline = '%s -f %s %s' % (program, util.email(sender),
54 ' '.join(map(util.email, recipients)))
55 55 ui.note(_('sending mail: %s\n') % cmdline)
56 56 fp = os.popen(cmdline, 'w')
57 57 fp.write(msg)
@@ -214,12 +214,6 def domain(author):
214 214 if f >= 0: author = author[:f]
215 215 return author
216 216
217 def email(author):
218 '''get email of author.'''
219 r = author.find('>')
220 if r == -1: r = None
221 return author[author.find('<')+1:r]
222
223 217 def person(author):
224 218 '''get name of author, or else username.'''
225 219 f = author.find('<')
@@ -257,7 +251,7 common_filters = {
257 251 "age": age,
258 252 "date": lambda x: util.datestr(x),
259 253 "domain": domain,
260 "email": email,
254 "email": util.email,
261 255 "escape": lambda x: cgi.escape(x, True),
262 256 "fill68": lambda x: fill(x, width=68),
263 257 "fill76": lambda x: fill(x, width=76),
@@ -1636,6 +1636,12 def shortuser(user):
1636 1636 user = user[:f]
1637 1637 return user
1638 1638
1639 def email(author):
1640 '''get email of author.'''
1641 r = author.find('>')
1642 if r == -1: r = None
1643 return author[author.find('<')+1:r]
1644
1639 1645 def ellipsis(text, maxlength=400):
1640 1646 """Trim string to at most maxlength (default: 400) characters."""
1641 1647 if len(text) <= maxlength:
General Comments 0
You need to be logged in to leave comments. Login now