patchbomb: add --confirm option to show series details and ask for confirmation
authorChristian Ebert <blacktrash@gmx.net>
Fri, 10 Sep 2010 15:32:22 +0200
changeset 12201 5bfa45651cf6
parent 12200 aebb39d45500
child 12202 d346089095ac
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.
hgext/patchbomb.py
tests/test-patchbomb.t
--- a/hgext/patchbomb.py	Fri Sep 10 15:32:14 2010 +0200
+++ b/hgext/patchbomb.py	Fri Sep 10 15:32:22 2010 +0200
@@ -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')),
--- a/tests/test-patchbomb.t	Fri Sep 10 15:32:14 2010 +0200
+++ b/tests/test-patchbomb.t	Fri Sep 10 15:32:22 2010 +0200
@@ -46,6 +46,23 @@
   +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
+  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