changeset 2707:4af7b178976a

patchbomb: optionally send patches as inline attachments
author Christian Ebert <blacktrash@gmx.net>
date Thu, 27 Jul 2006 22:28:03 +0200
parents 030d0abdf91b
children 084f07cacba0
files hgext/patchbomb.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Thu Jul 27 12:36:17 2006 -0700
+++ b/hgext/patchbomb.py	Thu Jul 27 22:28:03 2006 +0200
@@ -130,8 +130,13 @@
             while patch and not patch[0].strip(): patch.pop(0)
         if opts['diffstat']:
             body += cdiffstat('\n'.join(desc), patch) + '\n\n'
-        body += '\n'.join(patch)
-        msg = email.MIMEText.MIMEText(body)
+        if opts['attach']:
+            msg = email.MIMEMultipart.MIMEMultipart()
+            if body: msg.attach(email.MIMEText.MIMEText(body, 'plain'))
+            msg.attach(email.MIMEText.MIMEText('\n'.join(patch), 'x-patch'))
+        else:
+            body += '\n'.join(patch)
+            msg = email.MIMEText.MIMEText(body)
         if total == 1:
             subj = '[PATCH] ' + desc[0].strip()
         else:
@@ -274,7 +279,8 @@
 cmdtable = {
     'email':
     (patchbomb,
-     [('', 'bcc', [], 'email addresses of blind copy recipients'),
+     [('a', 'attach', None, 'send patches as inline attachments'),
+      ('', 'bcc', [], 'email addresses of blind copy recipients'),
       ('c', 'cc', [], 'email addresses of copy recipients'),
       ('d', 'diffstat', None, 'add diffstat output to messages'),
       ('f', 'from', '', 'email address of sender'),