# HG changeset patch # User Pierre-Yves David # Date 2014-12-03 01:35:21 # Node ID 11b215731e74a63b3136ad1a901f811c53925adb # Parent c14af817ab76dcf3a591bb7ddbd436476be95320 patchbomb: introduce a 'patchbomb.confirm' option When set to true, this option will make patchbomb always ask for confirmation before sending the email. Confirmation is a powerful way to prevent stupid mistakes when the sending patches. This should let me get rid of my global alias adding --confirm to hg email. I know that some people may get bitten when moving from a machine with confirm configured to a machine where it is not, but I think it is worth the risk. diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -52,6 +52,9 @@ overwritten by command line flags like - 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 + +You can set patchbomb to always ask for confirmation by setting +``patchbomb.confirm`` to true. ''' import os, errno, socket, tempfile, cStringIO @@ -430,9 +433,10 @@ 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``. The inclusion the - introduction can also be control using the ``patchbomb.intro`` option. (see - hg help patchbomb for details) + introductory message in ``.hg/last-email.txt``. + + The default behavior of this command can be customized through + configuration. (See :hg:`help patchbomb` for details) Examples:: @@ -553,7 +557,10 @@ def patchbomb(ui, repo, *revs, **opts): bcc = getaddrs('Bcc') or [] replyto = getaddrs('Reply-To') - if opts.get('diffstat') or opts.get('confirm'): + confirm = ui.configbool('patchbomb', 'confirm') + confirm |= bool(opts.get('diffstat') or opts.get('confirm')) + + if confirm: ui.write(_('\nFinal summary:\n\n'), label='patchbomb.finalsummary') ui.write(('From: %s\n' % sender), label='patchbomb.from') for addr in showaddrs: diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t --- a/tests/test-patchbomb.t +++ b/tests/test-patchbomb.t @@ -86,6 +86,26 @@ Mercurial-patchbomb/.* -> Mercurial-patc abort: patchbomb canceled [255] + $ hg --config ui.interactive=1 --config patchbomb.confirm=true email -n -f quux -t foo -c bar -r tip< n + > EOF + this patch series consists of 1 patches. + + + Final summary: + + From: quux + To: foo + Cc: bar + Subject: [PATCH] a + a | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + + are you sure you want to send (yn)? n + abort: patchbomb canceled + [255] + + Test diff.git is respected $ hg --config diff.git=True email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -r tip this patch series consists of 1 patches.