[PATCH 1 of 2] patchbomb: add config option for intro

Yann E. MORIN yann.morin.1998 at free.fr
Wed Feb 29 16:53:54 CST 2012


# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998 at free.fr>
# Date 1330383414 -3600
# Node ID e6fb31285eabdb9f3092860791be954ea826d82e
# Parent  a4413624d0146f1edaa712a32c36c3409209ed6a
patchbomb: add config option for intro

Currently, the user is always prompted for an introduction message
if the series has more than one patch. Yet, some projects have a
policy of 'no introduction message' (eg. Mercurial itself).

Although the user can select not to send such a message by entering
an empty subject, getting the prompt in the first place can be
counter-intuitive, and could lead the user to think that a message
is required.

Add a new config option in section [patchbomb] to disable sending
an introduction message, unless overriden by command line:

    [patchbomb]
    intro = [always|yes|auto|no]

with the following meaning:
    patchbomb.intro     prompt for intro?
    ----------------------------------------------------
    always|yes          yes, even if only one patch
    auto                yes, only if more than one patch
    no                  no, even if more than one patch

Before this patch, the default was equivalent to 'auto'. To keep
a consistent experience for users, this new config option defaults
to 'auto' if not set.

The --intro command line option overrides this setting, and will always
prompt for an introduction message (as is already the case currently,
so the behavior of --intro does not change).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -38,6 +38,18 @@
 Then you can use the :hg:`email` command to mail a series of
 changesets as a patchbomb.
 
+In the ``[patchbomb]`` section, you can also configure whether you want
+to prompt for sending introduction messages::
+
+  [patchbomb]
+  intro = [always|yes|auto|no]
+
+where ``always`` or ``yes`` will prompt even for single-patch series,
+``auto`` (the default) will prompt only if the series has more than one
+patch, and ``no`` will not prompt. This can be overriden with the
+command-line option ``--intro``, which will always prompt for an
+introduction message.
+
 You can also either configure the method option in the email section
 to be a sendmail compatible mailer or fill out the [smtp] section so
 that the patchbomb extension can automatically send patchbombs
@@ -61,9 +73,14 @@
         prompt += ' [%s]' % default
     return ui.prompt(prompt + rest, default)
 
-def introwanted(opts, number):
+def introwanted(ui, opts, number):
     '''is an introductory message apparently wanted?'''
-    return number > 1 or opts.get('intro') or opts.get('desc')
+    introcfg = ui.config('patchbomb', 'intro')
+    if introcfg in ['always', 'yes'] or opts.get('intro') or opts.get('desc'):
+        return True
+    if number > 1 and (introcfg == 'auto' or not introcfg):
+        return True
+    return False
 
 def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered,
               patchname=None):
@@ -182,6 +199,12 @@
     :hg:`export`, one per message. The series starts with a "[PATCH 0
     of N]" introduction, which describes the series as a whole.
 
+    The default is to send an introduction message only if there is more
+    than one out-going changeset, or if the config option ``patchbomb.intro``
+    is set to either ``yes`` or ``always``. With --intro, you will be
+    prompted for an introductory message, even if there is only one
+    out-going message.
+
     Each patch email has a Subject line of "[PATCH M of N] ...", using
     the first line of the changeset description as the subject text.
     The message contains two or three parts. First, the changeset
@@ -356,7 +379,7 @@
                  % len(patches))
 
         # build the intro message, or skip it if the user declines
-        if introwanted(opts, len(patches)):
+        if introwanted(ui, opts, len(patches)):
             msg = makeintro(patches)
             if msg:
                 msgs.append(msg)


More information about the Mercurial-devel mailing list