# HG changeset patch # User Nicolas Dumazet # Date 1247624807 -32400 # Node ID bb3f8f692bc684797a93f2fedea8c7e6733d9d7a # Parent 94114ea3503d9a9eed4c42e0417b87769401f199 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] diff -r 94114ea3503d -r bb3f8f692bc6 hgext/patchbomb.py --- 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')), ] diff -r 94114ea3503d -r bb3f8f692bc6 tests/test-patchbomb --- a/tests/test-patchbomb Wed Aug 12 12:07:11 2009 -0500 +++ b/tests/test-patchbomb Wed Jul 15 11:26:47 2009 +0900 @@ -151,3 +151,19 @@ hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar --in-reply-to baz \ -r 0:1 | fixheaders + +echo "% test single flag for single patch" +hg email --date '1970-1-1 0:1' -n --flag fooFlag -f quux -t foo -c bar -s test \ + -r 2 | fixheaders + +echo "% test single flag for multiple patches" +hg email --date '1970-1-1 0:1' -n --flag fooFlag -f quux -t foo -c bar -s test \ + -r 0:1 | fixheaders + +echo "% test mutiple flags for single patch" +hg email --date '1970-1-1 0:1' -n --flag fooFlag --flag barFlag -f quux -t foo \ + -c bar -s test -r 2 | fixheaders + +echo "% test multiple flags for multiple patches" +hg email --date '1970-1-1 0:1' -n --flag fooFlag --flag barFlag -f quux -t foo \ + -c bar -s test -r 0:1 | fixheaders diff -r 94114ea3503d -r bb3f8f692bc6 tests/test-patchbomb.out --- a/tests/test-patchbomb.out Wed Aug 12 12:07:11 2009 -0500 +++ b/tests/test-patchbomb.out Wed Jul 15 11:26:47 2009 +0900 @@ -1254,3 +1254,215 @@ @@ -0,0 +1,1 @@ +b +% test single flag for single patch +This patch series consists of 1 patches. + + +Displaying [PATCH fooFlag] test ... +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: [PATCH fooFlag] test +X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f +Message-Id: