[PATCH] notify: no charset conversion when testing

Christian Ebert blacktrash at gmx.net
Mon Dec 1 08:33:56 CST 2008


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1228141979 -3600
# Node ID a65f638e219cec49b0a1bc1e5516caf3ecbc670b
# Parent  79d1bb737c16b343e33be7cd7e22dcc4e7bfab0b
notify: no charset conversion when testing

Same as for patchbomb.

diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -157,7 +157,9 @@
                 for user in users.split(','):
                     subs[self.fixmail(user)] = 1
         subs = util.sort(subs)
-        return [mail.addressencode(self.ui, s, self.charsets) for s in subs]
+        show = self.ui.configbool('notify', 'test', True)
+        return [mail.addressencode(self.ui, s, self.charsets, show)
+                for s in subs]
 
     def url(self, path=None):
         return self.ui.config('web', 'baseurl') + (path or self.root)
@@ -186,7 +188,8 @@
         # create fresh mime message from msg body
         text = msg.get_payload()
         # for notification prefer readability over data precision
-        msg = mail.mimeencode(self.ui, text, self.charsets)
+        show = self.ui.configbool('notify', 'test', True)
+        msg = mail.mimeencode(self.ui, text, self.charsets, show)
 
         def fix_subject(subject):
             '''try to make subject line exist and be useful.'''
@@ -201,7 +204,8 @@
             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)
+            msg['Subject'] = mail.headencode(self.ui, subject,
+                                             self.charsets, show)
 
         def fix_sender(sender):
             '''try to make message have proper sender.'''
@@ -210,7 +214,8 @@
                 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)
+            msg['From'] = mail.addressencode(self.ui, sender,
+                                             self.charsets, show)
 
         msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2")
         fix_subject(subject)
@@ -224,7 +229,7 @@
         msg['To'] = ', '.join(self.subs)
 
         msgtext = msg.as_string(0)
-        if self.ui.configbool('notify', 'test', True):
+        if show:
             self.ui.write(msgtext)
             if not msgtext.endswith('\n'):
                 self.ui.write('\n')


More information about the Mercurial-devel mailing list