patchbomb: attachment options changed
authorDennis Schoen <ds@1d10t.de>
Mon, 31 Dec 2007 16:18:17 +0100
changeset 5819 89ea99c7bdfd
parent 5818 77775ae8d5d9
child 5820 3a1ffc1da32c
patchbomb: attachment options changed '-a/--attach' send patches as attachment '-i/--inline' sends patches as inline attachment (old behavior of -a/--attach)
hgext/patchbomb.py
--- a/hgext/patchbomb.py	Fri Jan 04 16:11:01 2008 +0100
+++ b/hgext/patchbomb.py	Mon Dec 31 16:18:17 2007 +0100
@@ -162,9 +162,10 @@
         if not node:
             raise ValueError
 
-        #body = ('\n'.join(desc[1:]).strip() or
-        #        'Patch subject is complete summary.')
-        #body += '\n\n\n'
+        if opts['attach']:
+             body = ('\n'.join(desc[1:]).strip() or
+                   'Patch subject is complete summary.')
+             body += '\n\n\n'
 
         if opts.get('plain'):
             while patch and patch[0].startswith('# '):
@@ -175,7 +176,7 @@
                 patch.pop(0)
         if opts.get('diffstat'):
             body += cdiffstat('\n'.join(desc), patch) + '\n\n'
-        if opts.get('attach'):
+        if opts.get('attach') or opts.get('inline'):
             msg = email.MIMEMultipart.MIMEMultipart()
             if body:
                 msg.attach(email.MIMEText.MIMEText(body, 'plain'))
@@ -191,7 +192,10 @@
                                                   binnode, idx, total)
             else:
                 patchname = cmdutil.make_filename(repo, '%b.patch', binnode)
-            p['Content-Disposition'] = 'inline; filename=' + patchname
+            disposition = 'inline'
+            if opts['attach']:
+                disposition = 'attachment'
+            p['Content-Disposition'] = disposition + '; filename=' + patchname
             msg.attach(p)
         else:
             body += '\n'.join(patch)
@@ -430,7 +434,8 @@
 cmdtable = {
     "email":
         (patchbomb,
-         [('a', 'attach', None, _('send patches as inline attachments')),
+         [('a', 'attach', None, _('send patches as attachments')),
+          ('i', 'inline', 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')),