Mercurial > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
9345:94114ea3503d | 9346:bb3f8f692bc6 |
---|---|
160 msg.attach(p) | 160 msg.attach(p) |
161 else: | 161 else: |
162 body += '\n'.join(patch) | 162 body += '\n'.join(patch) |
163 msg = mail.mimetextpatch(body, display=opts.get('test')) | 163 msg = mail.mimetextpatch(body, display=opts.get('test')) |
164 | 164 |
165 flag = ' '.join(opts.get('flag')) | |
166 if flag: | |
167 flag = ' ' + flag | |
168 | |
165 subj = desc[0].strip().rstrip('. ') | 169 subj = desc[0].strip().rstrip('. ') |
166 if total == 1 and not opts.get('intro'): | 170 if total == 1 and not opts.get('intro'): |
167 subj = '[PATCH] ' + (opts.get('subject') or subj) | 171 subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj) |
168 else: | 172 else: |
169 tlen = len(str(total)) | 173 tlen = len(str(total)) |
170 subj = '[PATCH %0*d of %d] %s' % (tlen, idx, total, subj) | 174 subj = '[PATCH %0*d of %d%s] %s' % (tlen, idx, total, flag, subj) |
171 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test')) | 175 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test')) |
172 msg['X-Mercurial-Node'] = node | 176 msg['X-Mercurial-Node'] = node |
173 return msg, subj | 177 return msg, subj |
174 | 178 |
175 def patchbomb(ui, repo, *revs, **opts): | 179 def patchbomb(ui, repo, *revs, **opts): |
320 msgs.append(msg) | 324 msgs.append(msg) |
321 | 325 |
322 if len(patches) > 1 or opts.get('intro'): | 326 if len(patches) > 1 or opts.get('intro'): |
323 tlen = len(str(len(patches))) | 327 tlen = len(str(len(patches))) |
324 | 328 |
325 subj = '[PATCH %0*d of %d] %s' % ( | 329 flag = ' '.join(opts.get('flag')) |
326 tlen, 0, len(patches), | 330 if flag: |
327 opts.get('subject') or | 331 subj = '[PATCH %0*d of %d %s] ' % (tlen, 0, len(patches), flag) |
328 prompt(ui, 'Subject:', | 332 else: |
329 rest=' [PATCH %0*d of %d] ' % (tlen, 0, len(patches)))) | 333 subj = '[PATCH %0*d of %d] ' % (tlen, 0, len(patches)) |
334 subj += opts.get('subject') or prompt(ui, 'Subject:', rest=subj, | |
335 default='None') | |
330 | 336 |
331 body = '' | 337 body = '' |
332 if opts.get('diffstat'): | 338 if opts.get('diffstat'): |
333 d = cdiffstat(ui, _('Final summary:\n'), jumbo) | 339 d = cdiffstat(ui, _('Final summary:\n'), jumbo) |
334 if d: | 340 if d: |
475 _('write messages to mbox file instead of sending them')), | 481 _('write messages to mbox file instead of sending them')), |
476 ('s', 'subject', '', | 482 ('s', 'subject', '', |
477 _('subject of first message (intro or single patch)')), | 483 _('subject of first message (intro or single patch)')), |
478 ('', 'in-reply-to', '', | 484 ('', 'in-reply-to', '', |
479 _('message identifier to reply to')), | 485 _('message identifier to reply to')), |
486 ('', 'flag', [], _('flags to add in subject prefixes')), | |
480 ('t', 'to', [], _('email addresses of recipients')), | 487 ('t', 'to', [], _('email addresses of recipients')), |
481 ] | 488 ] |
482 | 489 |
483 | 490 |
484 cmdtable = { | 491 cmdtable = { |