[PATCH 2 of 2] patchbomb: display series summary and ask for confirmation

Christian Ebert blacktrash at gmx.net
Fri Jan 29 10:55:04 CST 2010


# HG changeset patch
# User sender
# Date 1264783904 0
# Node ID 0e75f6145d7d9571fc5578b4bcf5e756d6d1a70f
# Parent  765b92675e33139e0358c83202e7b10df9176904
patchbomb: display series summary and ask for confirmation

The prompt can be avoided with -y/--noninteractive.

Confirmation check summary:

Subject: only with -v/--verbose
[ ... all subjects of series ... ]
From: sender
To: recipient(s) or prompt for To
Cc: carbon copy recipients
Bcc: blind carbon copy recipients

test-patchbomb does not change as it runs in noninteractive mode.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -386,20 +386,35 @@
 
     def getaddrs(opt, prpt=None, default=None):
         if opts.get(opt):
+            if ui.interactive():
+                ui.write('%s: %s\n'
+                         % (opt.capitalize(), ', '.join(opts.get(opt))))
             return mail.addrlistencode(ui, opts.get(opt), _charsets,
                                        opts.get('test'))
 
-        addrs = (ui.config('email', opt) or
-                 ui.config('patchbomb', opt) or '')
+        addrs = ui.config('email', opt) or ui.config('patchbomb', opt) or ''
         if not addrs and prpt:
             addrs = prompt(ui, prpt, default)
+        elif addrs and ui.interactive():
+            ui.write('%s: %s\n' % (opt.capitalize(), addrs))
+        return mail.addrlistencode(ui, [addrs], _charsets, opts.get('test'))
 
-        return mail.addrlistencode(ui, [addrs], _charsets, opts.get('test'))
+    if ui.interactive():
+        if ui.verbose:
+            displaymsgs = ((opts.get('subject') or not opts.get('desc')) and
+                           msgs or msgs[1:])
+            for m, subj in displaymsgs:
+                ui.write('Subject: %s\n' % subj)
+        ui.write('From: %s\n' % sender)
 
     to = getaddrs('to', 'To')
     cc = getaddrs('cc')
     bcc = getaddrs('bcc')
 
+    resp = prompt(ui, _('are you sure you want to send?'), 'y')
+    if resp.lower() != 'y':
+        return
+
     ui.write('\n')
 
     parent = opts.get('in_reply_to') or None


More information about the Mercurial-devel mailing list