[PATCH 2 of 2] patchbomb: rename email function

Augie Fackler raf at durin42.com
Tue Dec 1 14:52:12 UTC 2015


On Sun, Nov 29, 2015 at 12:54:35AM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1448779883 0
> #      Sun Nov 29 06:51:23 2015 +0000
> # Node ID af026d08e42849216b25bf65859ea0aeb6ae2a0d
> # Parent  e9ba1888f28876c339fc1532108df246a60558a5
> patchbomb: rename email function

Sure, seems fine. Queued, thanks.

>
> I see no reason for the function not to be email ...
>
> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
> --- a/hgext/patchbomb.py
> +++ b/hgext/patchbomb.py
> @@ -58,7 +58,7 @@
>  '''
>
>  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 @@
>          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 @@
>              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 @@
>      ('', '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 @@
>          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 @@
>              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 @@
>                  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 @@
>                  # 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())
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list