hgext/patchbomb.py
changeset 4599 88fc92b0b821
parent 4597 ec431334e4fc
child 4600 64c415d2553a
equal deleted inserted replaced
4598:b25ee3f8f714 4599:88fc92b0b821
    42 #
    42 #
    43 # To avoid sending patches prematurely, it is a good idea to first run
    43 # To avoid sending patches prematurely, it is a good idea to first run
    44 # the "email" command with the "-n" option (test only).  You will be
    44 # the "email" command with the "-n" option (test only).  You will be
    45 # prompted for an email recipient address, a subject an an introductory
    45 # prompted for an email recipient address, a subject an an introductory
    46 # message describing the patches of your patchbomb.  Then when all is
    46 # message describing the patches of your patchbomb.  Then when all is
    47 # done, your pager will be fired up once for each patchbomb message, so
    47 # done, patchbomb messages are displayed. If PAGER environment variable
       
    48 # is set, your pager will be fired up once for each patchbomb message, so
    48 # you can verify everything is alright.
    49 # you can verify everything is alright.
    49 #
    50 #
    50 # The "-m" (mbox) option is also very useful.  Instead of previewing
    51 # The "-m" (mbox) option is also very useful.  Instead of previewing
    51 # each patchbomb message in a pager or sending the messages directly,
    52 # each patchbomb message in a pager or sending the messages directly,
    52 # it will create a UNIX mailbox file with the patch emails.  This
    53 # it will create a UNIX mailbox file with the patch emails.  This
   379         if cc: m['Cc']  = ', '.join(cc)
   380         if cc: m['Cc']  = ', '.join(cc)
   380         if bcc: m['Bcc'] = ', '.join(bcc)
   381         if bcc: m['Bcc'] = ', '.join(bcc)
   381         if opts['test']:
   382         if opts['test']:
   382             ui.status('Displaying ', m['Subject'], ' ...\n')
   383             ui.status('Displaying ', m['Subject'], ' ...\n')
   383             ui.flush()
   384             ui.flush()
   384             fp = os.popen(os.getenv('PAGER', 'more'), 'w')
   385             if 'PAGER' in os.environ:
       
   386                 fp = os.popen(os['PAGER'], 'w')
       
   387             else:
       
   388                 fp = ui
   385             try:
   389             try:
   386                 fp.write(m.as_string(0))
   390                 fp.write(m.as_string(0))
   387                 fp.write('\n')
   391                 fp.write('\n')
   388             except IOError, inst:
   392             except IOError, inst:
   389                 if inst.errno != errno.EPIPE:
   393                 if inst.errno != errno.EPIPE:
   390                     raise
   394                     raise
   391             fp.close()
   395             if fp is not ui:
       
   396                 fp.close()
   392         elif opts['mbox']:
   397         elif opts['mbox']:
   393             ui.status('Writing ', m['Subject'], ' ...\n')
   398             ui.status('Writing ', m['Subject'], ' ...\n')
   394             fp = open(opts['mbox'], m.has_key('In-Reply-To') and 'ab+' or 'wb+')
   399             fp = open(opts['mbox'], m.has_key('In-Reply-To') and 'ab+' or 'wb+')
   395             date = util.datestr(date=start_time,
   400             date = util.datestr(date=start_time,
   396                     format='%a %b %d %H:%M:%S %Y', timezone=False)
   401                     format='%a %b %d %H:%M:%S %Y', timezone=False)