diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -43,6 +43,15 @@ to be a sendmail compatible mailer or fi that the patchbomb extension can automatically send patchbombs directly from the commandline. See the [email] and [smtp] sections in hgrc(5) for details. + +You can control the default inclusion of an introduction message with the +``patchbomb.intro`` configuration option. The configuration is always +overwritten by command line flags like --intro and --desc:: + + [patchbomb] + intro=auto # include introduction message if more than 1 patch (default) + intro=never # never include an introduction message + intro=always # always include an introduction message ''' import os, errno, socket, tempfile, cStringIO @@ -66,9 +75,23 @@ def prompt(ui, prompt, default=None, res 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') + introconfig = ui.config('patchbomb', 'intro', 'auto') + if opts.get('intro') or opts.get('desc'): + intro = True + elif introconfig == 'always': + intro = True + elif introconfig == 'never': + intro = False + elif introconfig == 'auto': + intro = 1 < number + else: + ui.write_err(_('warning: invalid patchbomb.intro value "%s"\n') + % introconfig) + ui.write_err(_('(should be one of always, never, auto)\n')) + intro = 1 < number + return intro def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered, patchname=None): @@ -287,7 +310,7 @@ def _getpatchmsgs(repo, sender, patches, % 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(repo, sender, patches, **opts) if msg: msgs.append(msg) @@ -407,7 +430,9 @@ def patchbomb(ui, repo, *revs, **opts): for each patchbomb message, so you can verify everything is alright. In case email sending fails, you will find a backup of your series - introductory message in ``.hg/last-email.txt``. + introductory message in ``.hg/last-email.txt``. The inclusion the + introduction can also be control using the ``patchbomb.intro`` option. (see + hg help patchbomb for details) Examples:: diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t --- a/tests/test-patchbomb.t +++ b/tests/test-patchbomb.t @@ -2663,4 +2663,127 @@ dest#branch URIs: +d - $ cd .. +Test introduction configuration +================================= + + $ echo '[patchbomb]' >> $HGRCPATH + +"auto" setting +---------------- + + $ echo 'intro=auto' >> $HGRCPATH + +single rev + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' | grep "Write the introductory message for the patch series." + [1] + +single rev + flag + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' --intro | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + + +Multi rev + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '9::' | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + +"never" setting +----------------- + + $ echo 'intro=never' >> $HGRCPATH + +single rev + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' | grep "Write the introductory message for the patch series." + [1] + +single rev + flag + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' --intro | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + + +Multi rev + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '9::' | grep "Write the introductory message for the patch series." + [1] + +Multi rev + flag + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '9::' --intro | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + +"always" setting +----------------- + + $ echo 'intro=always' >> $HGRCPATH + +single rev + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + +single rev + flag + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' --intro | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + + +Multi rev + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '9::' | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + +Multi rev + flag + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '9::' --intro | grep "Write the introductory message for the patch series." + Write the introductory message for the patch series. + +bad value setting +----------------- + + $ echo 'intro=mpmwearaclownnose' >> $HGRCPATH + +single rev + + $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' + From [test]: test + this patch series consists of 1 patches. + + warning: invalid patchbomb.intro value "mpmwearaclownnose" + (should be one of always, never, auto) + Cc: + + displaying [PATCH] test ... + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Subject: [PATCH] test + X-Mercurial-Node: 3b6f1ec9dde933a40a115a7990f8b320477231af + X-Mercurial-Series-Index: 1 + X-Mercurial-Series-Total: 1 + Message-Id: <3b6f1ec9dde933a40a11*> (glob) + X-Mercurial-Series-Id: <3b6f1ec9dde933a40a11.*> (glob) + User-Agent: Mercurial-patchbomb/* (glob) + Date: Tue, 01 Jan 1980 00:01:00 +0000 + From: test + To: foo + + # HG changeset patch + # User test + # Date 5 0 + # Thu Jan 01 00:00:05 1970 +0000 + # Branch test + # Node ID 3b6f1ec9dde933a40a115a7990f8b320477231af + # Parent 2f9fa9b998c5fe3ac2bd9a2b14bfcbeecbc7c268 + dd + + diff -r 2f9fa9b998c5 -r 3b6f1ec9dde9 d + --- a/d Thu Jan 01 00:00:04 1970 +0000 + +++ b/d Thu Jan 01 00:00:05 1970 +0000 + @@ -1,1 +1,2 @@ + d + +d +