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

Christian Ebert blacktrash at gmx.net
Fri Jan 29 15:23:33 CST 2010


# HG changeset patch
# User sender
# Date 1264799540 0
# Node ID fc5a9a5f0f96a3f32f14c983368a2d589dfe9e7c
# Parent  b0d68e68c9185059432a31b0357aaf2aedcd975f
patchbomb: with --verbose display series summary and ask for confirmation

Confirmation check summary:

Subject: [patch 0 of x [flags]] subject of intro or single patch
Subject: [patch 1 of x [flags]] subject
[ ... ]
From: sender
To: recipient(s) or prompt for To
Cc: carbon copy recipients
Bcc: blind carbon copy recipients

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -386,21 +386,37 @@
 
     def getaddrs(opt, prpt=None, default=None):
         if opts.get(opt):
+            if ui.interactive():
+                ui.note('%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.note('%s: %s\n' % (opt.capitalize(), addrs))
 
         return mail.addrlistencode(ui, [addrs], _charsets, opts.get('test'))
 
+    if ui.interactive():
+        # verbose: display 1st subject only when
+        # 1) subject was not prompted for or 2) returning from editing intro
+        displaymsgs = ((opts.get('subject') or not opts.get('desc')) and
+                       msgs or msgs[1:])
+        for m, subj in displaymsgs:
+            ui.note('Subject: %s\n' % subj)
+        ui.note('From: %s\n' % sender)
+
     to = getaddrs('to', 'To')
     cc = getaddrs('cc', not opts.get('to') and 'Cc', '')
     bcc = getaddrs('bcc')
 
-    ui.write('\n')
+    if ui.verbose:
+        resp = prompt(ui, _('are you sure you want to send?'), 'y')
+        if resp.lower() != 'y':
+            return
 
     parent = opts.get('in_reply_to') or None
     # angle brackets may be omitted, they're not semantically part of the msg-id


More information about the Mercurial-devel mailing list