hgext/patchbomb.py
changeset 23487 c14af817ab76
parent 23486 1de214837f5e
child 23488 11b215731e74
equal deleted inserted replaced
23486:1de214837f5e 23487:c14af817ab76
    41 You can also either configure the method option in the email section
    41 You can also either configure the method option in the email section
    42 to be a sendmail compatible mailer or fill out the [smtp] section so
    42 to be a sendmail compatible mailer or fill out the [smtp] section so
    43 that the patchbomb extension can automatically send patchbombs
    43 that the patchbomb extension can automatically send patchbombs
    44 directly from the commandline. See the [email] and [smtp] sections in
    44 directly from the commandline. See the [email] and [smtp] sections in
    45 hgrc(5) for details.
    45 hgrc(5) for details.
       
    46 
       
    47 You can control the default inclusion of an introduction message with the
       
    48 ``patchbomb.intro`` configuration option. The configuration is always
       
    49 overwritten by command line flags like --intro and --desc::
       
    50 
       
    51   [patchbomb]
       
    52   intro=auto   # include introduction message if more than 1 patch (default)
       
    53   intro=never  # never include an introduction message
       
    54   intro=always # always include an introduction message
    46 '''
    55 '''
    47 
    56 
    48 import os, errno, socket, tempfile, cStringIO
    57 import os, errno, socket, tempfile, cStringIO
    49 import email
    58 import email
    50 # On python2.4 you have to import these by name or they fail to
    59 # On python2.4 you have to import these by name or they fail to
    64 def prompt(ui, prompt, default=None, rest=':'):
    73 def prompt(ui, prompt, default=None, rest=':'):
    65     if default:
    74     if default:
    66         prompt += ' [%s]' % default
    75         prompt += ' [%s]' % default
    67     return ui.prompt(prompt + rest, default)
    76     return ui.prompt(prompt + rest, default)
    68 
    77 
    69 def introwanted(opts, number):
    78 def introwanted(ui, opts, number):
    70     '''is an introductory message apparently wanted?'''
    79     '''is an introductory message apparently wanted?'''
    71     return number > 1 or opts.get('intro') or opts.get('desc')
    80     introconfig = ui.config('patchbomb', 'intro', 'auto')
       
    81     if opts.get('intro') or opts.get('desc'):
       
    82         intro = True
       
    83     elif introconfig == 'always':
       
    84         intro = True
       
    85     elif introconfig == 'never':
       
    86         intro = False
       
    87     elif introconfig == 'auto':
       
    88         intro = 1 < number
       
    89     else:
       
    90         ui.write_err(_('warning: invalid patchbomb.intro value "%s"\n')
       
    91                      % introconfig)
       
    92         ui.write_err(_('(should be one of always, never, auto)\n'))
       
    93         intro = 1 < number
       
    94     return intro
    72 
    95 
    73 def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered,
    96 def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered,
    74               patchname=None):
    97               patchname=None):
    75 
    98 
    76     desc = []
    99     desc = []
   285 
   308 
   286     ui.write(_('this patch series consists of %d patches.\n\n')
   309     ui.write(_('this patch series consists of %d patches.\n\n')
   287              % len(patches))
   310              % len(patches))
   288 
   311 
   289     # build the intro message, or skip it if the user declines
   312     # build the intro message, or skip it if the user declines
   290     if introwanted(opts, len(patches)):
   313     if introwanted(ui, opts, len(patches)):
   291         msg = _makeintro(repo, sender, patches, **opts)
   314         msg = _makeintro(repo, sender, patches, **opts)
   292         if msg:
   315         if msg:
   293             msgs.append(msg)
   316             msgs.append(msg)
   294 
   317 
   295     # are we going to send more than one message?
   318     # are we going to send more than one message?
   405     Then when all is done, patchbomb messages are displayed. If the
   428     Then when all is done, patchbomb messages are displayed. If the
   406     PAGER environment variable is set, your pager will be fired up once
   429     PAGER environment variable is set, your pager will be fired up once
   407     for each patchbomb message, so you can verify everything is alright.
   430     for each patchbomb message, so you can verify everything is alright.
   408 
   431 
   409     In case email sending fails, you will find a backup of your series
   432     In case email sending fails, you will find a backup of your series
   410     introductory message in ``.hg/last-email.txt``.
   433     introductory message in ``.hg/last-email.txt``. The inclusion the
       
   434     introduction can also be control using the ``patchbomb.intro`` option. (see
       
   435     hg help patchbomb for details)
   411 
   436 
   412     Examples::
   437     Examples::
   413 
   438 
   414       hg email -r 3000          # send patch 3000 only
   439       hg email -r 3000          # send patch 3000 only
   415       hg email -r 3000 -r 3001  # send patches 3000 and 3001
   440       hg email -r 3000 -r 3001  # send patches 3000 and 3001