Mercurial > hg-stable
changeset 7705:c55e68e8f256
notify: remove subfunctions that are called only once
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Sun, 25 Jan 2009 11:10:51 +0100 |
parents | 30d1d313370b |
children | 0ae7f0b312ea |
files | hgext/notify.py |
diffstat | 1 files changed, 21 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/notify.py Sat Jan 24 00:13:49 2009 +0100 +++ b/hgext/notify.py Sun Jan 25 11:10:51 2009 +0100 @@ -196,35 +196,29 @@ for k, v in headers: msg[k] = v - def fix_subject(subject): - '''try to make subject line exist and be useful.''' + msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") - if not subject: - if count > 1: - subject = _('%s: %d new changesets') % (self.root, count) - else: - changes = self.repo.changelog.read(node) - s = changes[4].lstrip().split('\n', 1)[0].rstrip() - subject = '%s: %s' % (self.root, s) - maxsubject = int(self.ui.config('notify', 'maxsubject', 67)) - if maxsubject and len(subject) > maxsubject: - subject = subject[:maxsubject-3] + '...' - msg['Subject'] = mail.headencode(self.ui, subject, - self.charsets, self.test) + # try to make subject line exist and be useful + if not subject: + if count > 1: + subject = _('%s: %d new changesets') % (self.root, count) + else: + changes = self.repo.changelog.read(node) + s = changes[4].lstrip().split('\n', 1)[0].rstrip() + subject = '%s: %s' % (self.root, s) + maxsubject = int(self.ui.config('notify', 'maxsubject', 67)) + if maxsubject and len(subject) > maxsubject: + subject = subject[:maxsubject-3] + '...' + msg['Subject'] = mail.headencode(self.ui, subject, + self.charsets, self.test) - def fix_sender(sender): - '''try to make message have proper sender.''' - - if not sender: - sender = self.ui.config('email', 'from') or self.ui.username() - if '@' not in sender or '@localhost' in sender: - sender = self.fixmail(sender) - msg['From'] = mail.addressencode(self.ui, sender, - self.charsets, self.test) - - msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") - fix_subject(subject) - fix_sender(sender) + # try to make message have proper sender + if not sender: + sender = self.ui.config('email', 'from') or self.ui.username() + if '@' not in sender or '@localhost' in sender: + sender = self.fixmail(sender) + msg['From'] = mail.addressencode(self.ui, sender, + self.charsets, self.test) msg['X-Hg-Notification'] = 'changeset ' + short(node) if not msg['Message-Id']: