notify: remove subfunctions that are called only once
authorChristian Ebert <blacktrash@gmx.net>
Sun, 25 Jan 2009 11:10:51 +0100
changeset 7705 c55e68e8f256
parent 7704 30d1d313370b
child 7706 0ae7f0b312ea
notify: remove subfunctions that are called only once
hgext/notify.py
--- 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']: