Show More
@@ -70,7 +70,7 can push changes to, they can manage the | |||
|
70 | 70 | |
|
71 | 71 | from mercurial.i18n import _ |
|
72 | 72 | from mercurial import patch, cmdutil, templater, util, mail |
|
73 | import email.Parser, fnmatch, socket, time | |
|
73 | import email.Parser, email.Errors, fnmatch, socket, time | |
|
74 | 74 | |
|
75 | 75 | # template for single changeset can include email headers. |
|
76 | 76 | single_template = ''' |
@@ -180,20 +180,25 class notifier(object): | |||
|
180 | 180 | '''send message.''' |
|
181 | 181 | |
|
182 | 182 | p = email.Parser.Parser() |
|
183 | msg = p.parsestr(data) | |
|
183 | try: | |
|
184 | msg = p.parsestr(data) | |
|
185 | except email.Errors.MessageParseError, inst: | |
|
186 | raise util.Abort(inst) | |
|
184 | 187 | |
|
185 | 188 | # store sender and subject |
|
186 | 189 | sender, subject = msg['From'], msg['Subject'] |
|
187 | 190 | del msg['From'], msg['Subject'] |
|
188 | # store remaining headers | |
|
189 | headers = msg.items() | |
|
190 |
# create fresh mime message from |
|
|
191 | text = msg.get_payload() | |
|
192 | # for notification prefer readability over data precision | |
|
193 | msg = mail.mimeencode(self.ui, text, self.charsets, self.test) | |
|
194 | # reinstate custom headers | |
|
195 | for k, v in headers: | |
|
196 | msg[k] = v | |
|
191 | ||
|
192 | if not msg.is_multipart(): | |
|
193 | # create fresh mime message from scratch | |
|
194 | # (multipart templates must take care of this themselves) | |
|
195 | headers = msg.items() | |
|
196 | payload = msg.get_payload() | |
|
197 | # for notification prefer readability over data precision | |
|
198 | msg = mail.mimeencode(self.ui, payload, self.charsets, self.test) | |
|
199 | # reinstate custom headers | |
|
200 | for k, v in headers: | |
|
201 | msg[k] = v | |
|
197 | 202 | |
|
198 | 203 | msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") |
|
199 | 204 |
@@ -81,7 +81,10 class _demandmod(object): | |||
|
81 | 81 | def _demandimport(name, globals=None, locals=None, fromlist=None, level=None): |
|
82 | 82 | if not locals or name in ignore or fromlist == ('*',): |
|
83 | 83 | # these cases we can't really delay |
|
84 | return _origimport(name, globals, locals, fromlist) | |
|
84 | if level is None: | |
|
85 | return _origimport(name, globals, locals, fromlist) | |
|
86 | else: | |
|
87 | return _origimport(name, globals, locals, fromlist, level) | |
|
85 | 88 | elif not fromlist: |
|
86 | 89 | # import a [as b] |
|
87 | 90 | if '.' in name: # a.b |
General Comments 0
You need to be logged in to leave comments.
Login now