diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -58,7 +58,7 @@ You can set patchbomb to always ask for ''' import os, errno, socket, tempfile, cStringIO -import email +import email as emailmod from mercurial import cmdutil, commands, hg, mail, patch, util, error from mercurial import scmutil @@ -155,7 +155,7 @@ def makepatch(ui, repo, patchlines, opts body += '\n'.join(patchlines) if addattachment: - msg = email.MIMEMultipart.MIMEMultipart() + msg = emailmod.MIMEMultipart.MIMEMultipart() if body: msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test'))) p = mail.mimetextpatch('\n'.join(patchlines), 'x-patch', @@ -272,15 +272,15 @@ def _getbundlemsgs(repo, sender, bundle, or prompt(ui, 'Subject:', 'A bundle for your repository')) body = _getdescription(repo, '', sender, **opts) - msg = email.MIMEMultipart.MIMEMultipart() + msg = emailmod.MIMEMultipart.MIMEMultipart() if body: msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test'))) - datapart = email.MIMEBase.MIMEBase('application', 'x-mercurial-bundle') + datapart = emailmod.MIMEBase.MIMEBase('application', 'x-mercurial-bundle') datapart.set_payload(bundle) bundlename = '%s.hg' % opts.get('bundlename', 'bundle') datapart.add_header('Content-Disposition', 'attachment', filename=bundlename) - email.Encoders.encode_base64(datapart) + emailmod.Encoders.encode_base64(datapart) msg.attach(datapart) msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test')) return [(msg, subj, None)] @@ -403,7 +403,7 @@ emailopts = [ ('', 'intro', None, _('send an introduction email for a single patch')), ] + emailopts + commands.remoteopts, _('hg email [OPTION]... [DEST]...')) -def patchbomb(ui, repo, *revs, **opts): +def email(ui, repo, *revs, **opts): '''send changesets by email By default, diffs are sent in the format generated by @@ -641,7 +641,7 @@ def patchbomb(ui, repo, *revs, **opts): if not parent.endswith('>'): parent += '>' - sender_addr = email.Utils.parseaddr(sender)[1] + sender_addr = emailmod.Utils.parseaddr(sender)[1] sender = mail.addressencode(ui, sender, _charsets, opts.get('test')) sendmail = None firstpatch = None @@ -660,7 +660,7 @@ def patchbomb(ui, repo, *revs, **opts): parent = m['Message-Id'] m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version() - m['Date'] = email.Utils.formatdate(start_time[0], localtime=True) + m['Date'] = emailmod.Utils.formatdate(start_time[0], localtime=True) start_time = (start_time[0] + 1, start_time[1]) m['From'] = sender @@ -678,7 +678,7 @@ def patchbomb(ui, repo, *revs, **opts): fp = util.popen(os.environ['PAGER'], 'w') else: fp = ui - generator = email.Generator.Generator(fp, mangle_from_=False) + generator = emailmod.Generator.Generator(fp, mangle_from_=False) try: generator.flatten(m, 0) fp.write('\n') @@ -702,7 +702,7 @@ def patchbomb(ui, repo, *revs, **opts): # Exim does not remove the Bcc field del m['Bcc'] fp = cStringIO.StringIO() - generator = email.Generator.Generator(fp, mangle_from_=False) + generator = emailmod.Generator.Generator(fp, mangle_from_=False) generator.flatten(m, 0) sendmail(sender_addr, to + bcc + cc, fp.getvalue())