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