[PATCH 4 of 4] patchbomb: add --confirm option to show series details and ask for confirmation

Christian Ebert blacktrash at gmx.net
Wed Sep 8 02:03:57 CDT 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1283929417 -7200
# Node ID 02313180d2d36ce25d9927126c59f795356b9028
# Parent  dfe41fdb339d125f73954d8d43f792152656697d
patchbomb: add --confirm option to show series details and ask for confirmation

--confirm presents same prompt as --diffstat, but does not write
a diffstat to the messages' bodies.

A simple test simulating a negative response is included.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -22,9 +22,9 @@
 and References headers, so they will show up as a sequence in threaded
 mail and news readers, and in mail archives.
 
-With the -d/--diffstat option, you will be presented with a final
-summary of all messages and asked for confirmation before the messages
-are sent.
+With the -d/--diffstat or -c/--confirm options, you will be presented
+with a final summary of all messages and asked for confirmation before
+the messages are sent.
 
 To configure other defaults, add a section like this to your hgrc
 file::
@@ -412,7 +412,7 @@
     bcc = getaddrs('bcc')
     replyto = getaddrs('reply-to')
 
-    if opts.get('diffstat'):
+    if opts.get('diffstat') or opts.get('confirm'):
         ui.write(_('\nFinal summary:\n\n'))
         ui.write('From: %s\n' % sender)
         for addr in showaddrs:
@@ -509,6 +509,7 @@
           ('i', 'inline', None, _('send patches as inline attachments')),
           ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
           ('c', 'cc', [], _('email addresses of copy recipients')),
+          ('', 'confirm', None, _('ask for confirmation before sending')),
           ('d', 'diffstat', None, _('add diffstat output to messages')),
           ('', 'date', '', _('use the given date as the sending date')),
           ('', 'desc', '', _('use the given file as the series description')),
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -46,6 +46,25 @@
   +a
   
 
+  $ hg --config ui.interactive=1 email --confirm -n -f quux -t foo -c bar -r tip<<EOF
+  > n
+  > EOF
+  This patch series consists of 1 patches.
+  
+  
+  Final summary:
+  
+  From: quux
+  To: foo
+  Cc: bar
+  Bcc:
+  Reply-To:
+  Subject: [PATCH] a
+   a |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
+  are you sure you want to send (yn)? abort: patchbomb canceled
+
   $ echo b > b
   $ hg commit -Amb -d '2 0'
   adding b


More information about the Mercurial-devel mailing list