comparison hgext/patchbomb.py @ 31489:5b2e1689b24d

patchbomb: use modern pager to display -n/--test result (BC) This should provide more consistent UX, but is a BC because the pager will no longer be fired up for each message.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 25 Feb 2017 17:27:48 +0900
parents 6b8e1a08ef1d
children 8122cc5cb543
comparison
equal deleted inserted replaced
31488:766364caae14 31489:5b2e1689b24d
81 81
82 from mercurial.i18n import _ 82 from mercurial.i18n import _
83 from mercurial import ( 83 from mercurial import (
84 cmdutil, 84 cmdutil,
85 commands, 85 commands,
86 encoding,
87 error, 86 error,
88 formatter, 87 formatter,
89 hg, 88 hg,
90 mail, 89 mail,
91 node as nodemod, 90 node as nodemod,
496 files. 495 files.
497 496
498 With -n/--test, all steps will run, but mail will not be sent. 497 With -n/--test, all steps will run, but mail will not be sent.
499 You will be prompted for an email recipient address, a subject and 498 You will be prompted for an email recipient address, a subject and
500 an introductory message describing the patches of your patchbomb. 499 an introductory message describing the patches of your patchbomb.
501 Then when all is done, patchbomb messages are displayed. If the 500 Then when all is done, patchbomb messages are displayed.
502 PAGER environment variable is set, your pager will be fired up once
503 for each patchbomb message, so you can verify everything is alright.
504 501
505 In case email sending fails, you will find a backup of your series 502 In case email sending fails, you will find a backup of your series
506 introductory message in ``.hg/last-email.txt``. 503 introductory message in ``.hg/last-email.txt``.
507 504
508 The default behavior of this command can be customized through 505 The default behavior of this command can be customized through
717 if replyto: 714 if replyto:
718 m['Reply-To'] = ', '.join(replyto) 715 m['Reply-To'] = ', '.join(replyto)
719 if opts.get('test'): 716 if opts.get('test'):
720 ui.status(_('displaying '), subj, ' ...\n') 717 ui.status(_('displaying '), subj, ' ...\n')
721 ui.flush() 718 ui.flush()
722 if 'PAGER' in encoding.environ and not ui.plain(): 719 ui.pager('email')
723 fp = util.popen(encoding.environ['PAGER'], 'w') 720 generator = emailmod.Generator.Generator(ui, mangle_from_=False)
724 else:
725 fp = ui
726 generator = emailmod.Generator.Generator(fp, mangle_from_=False)
727 try: 721 try:
728 generator.flatten(m, 0) 722 generator.flatten(m, 0)
729 fp.write('\n') 723 ui.write('\n')
730 except IOError as inst: 724 except IOError as inst:
731 if inst.errno != errno.EPIPE: 725 if inst.errno != errno.EPIPE:
732 raise 726 raise
733 if fp is not ui:
734 fp.close()
735 else: 727 else:
736 if not sendmail: 728 if not sendmail:
737 sendmail = mail.connect(ui, mbox=mbox) 729 sendmail = mail.connect(ui, mbox=mbox)
738 ui.status(_('sending '), subj, ' ...\n') 730 ui.status(_('sending '), subj, ' ...\n')
739 ui.progress(_('sending'), i, item=subj, total=len(msgs), 731 ui.progress(_('sending'), i, item=subj, total=len(msgs),