--- a/hgext/notify.py Wed Aug 05 17:08:28 2009 +0200
+++ b/hgext/notify.py Wed Aug 05 17:21:29 2009 +0200
@@ -70,7 +70,7 @@
from mercurial.i18n import _
from mercurial import patch, cmdutil, templater, util, mail
-import email.Parser, fnmatch, socket, time
+import email.Parser, email.Errors, fnmatch, socket, time
# template for single changeset can include email headers.
single_template = '''
@@ -180,20 +180,25 @@
'''send message.'''
p = email.Parser.Parser()
- msg = p.parsestr(data)
+ try:
+ msg = p.parsestr(data)
+ except email.Errors.MessageParseError, inst:
+ raise util.Abort(inst)
# store sender and subject
sender, subject = msg['From'], msg['Subject']
del msg['From'], msg['Subject']
- # store remaining headers
- headers = msg.items()
- # 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, self.test)
- # reinstate custom headers
- for k, v in headers:
- msg[k] = v
+
+ if not msg.is_multipart():
+ # create fresh mime message from scratch
+ # (multipart templates must take care of this themselves)
+ headers = msg.items()
+ payload = msg.get_payload()
+ # for notification prefer readability over data precision
+ msg = mail.mimeencode(self.ui, payload, self.charsets, self.test)
+ # reinstate custom headers
+ for k, v in headers:
+ msg[k] = v
msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2")
--- a/mercurial/demandimport.py Wed Aug 05 17:08:28 2009 +0200
+++ b/mercurial/demandimport.py Wed Aug 05 17:21:29 2009 +0200
@@ -81,7 +81,10 @@
def _demandimport(name, globals=None, locals=None, fromlist=None, level=None):
if not locals or name in ignore or fromlist == ('*',):
# these cases we can't really delay
- return _origimport(name, globals, locals, fromlist)
+ if level is None:
+ return _origimport(name, globals, locals, fromlist)
+ else:
+ return _origimport(name, globals, locals, fromlist, level)
elif not fromlist:
# import a [as b]
if '.' in name: # a.b
--- a/mercurial/lsprof.py Wed Aug 05 17:08:28 2009 +0200
+++ b/mercurial/lsprof.py Wed Aug 05 17:21:29 2009 +0200
@@ -85,7 +85,7 @@
try:
mname = _fn2mod[code.co_filename]
except KeyError:
- for k, v in sys.modules.iteritems():
+ for k, v in list(sys.modules.iteritems()):
if v is None:
continue
if not hasattr(v, '__file__'):