diff hgext/patchbomb.py @ 9346:bb3f8f692bc6

patchbomb: add --flag to put flags in subject prefixes --flag foo uses: [PATCH foo] or [PATCH M of N foo] depending on the number of patches. Multiple flags are supported: --flag foo --flag bar gives [PATCH foo bar]
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Wed, 15 Jul 2009 11:26:47 +0900
parents ad95ea1c975a
children d051db8e9e44
line wrap: on
line diff
--- a/hgext/patchbomb.py	Wed Aug 12 12:07:11 2009 -0500
+++ b/hgext/patchbomb.py	Wed Jul 15 11:26:47 2009 +0900
@@ -162,12 +162,16 @@
         body += '\n'.join(patch)
         msg = mail.mimetextpatch(body, display=opts.get('test'))
 
+    flag = ' '.join(opts.get('flag'))
+    if flag:
+        flag = ' ' + flag
+
     subj = desc[0].strip().rstrip('. ')
     if total == 1 and not opts.get('intro'):
-        subj = '[PATCH] ' + (opts.get('subject') or subj)
+        subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj)
     else:
         tlen = len(str(total))
-        subj = '[PATCH %0*d of %d] %s' % (tlen, idx, total, subj)
+        subj = '[PATCH %0*d of %d%s] %s' % (tlen, idx, total, flag, subj)
     msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
     msg['X-Mercurial-Node'] = node
     return msg, subj
@@ -322,11 +326,13 @@
         if len(patches) > 1 or opts.get('intro'):
             tlen = len(str(len(patches)))
 
-            subj = '[PATCH %0*d of %d] %s' % (
-                tlen, 0, len(patches),
-                opts.get('subject') or
-                prompt(ui, 'Subject:',
-                       rest=' [PATCH %0*d of %d] ' % (tlen, 0, len(patches))))
+            flag = ' '.join(opts.get('flag'))
+            if flag:
+                subj = '[PATCH %0*d of %d %s] ' % (tlen, 0, len(patches), flag)
+            else:
+                subj = '[PATCH %0*d of %d] ' % (tlen, 0, len(patches))
+            subj += opts.get('subject') or prompt(ui, 'Subject:', rest=subj,
+                                                    default='None')
 
             body = ''
             if opts.get('diffstat'):
@@ -477,6 +483,7 @@
            _('subject of first message (intro or single patch)')),
           ('', 'in-reply-to', '',
            _('message identifier to reply to')),
+          ('', 'flag', [], _('flags to add in subject prefixes')),
           ('t', 'to', [], _('email addresses of recipients')),
          ]