patchbomb: Don't prompt for headers until sure we have revs to export.
authorBryan O'Sullivan <bos@serpentine.com>
Sun, 27 May 2007 13:29:04 -0700
changeset 4479 82bc6aef8b43
parent 4438 3900f684a150
child 4480 6b84c8d2f66f
patchbomb: Don't prompt for headers until sure we have revs to export. The prior behaviour was to always prompt for headers, and only then bomb out if there were actually no revs to send.
hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -250,23 +250,6 @@ def patchbomb(ui, repo, *revs, **opts):
     def genmsgid(id):
         return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
 
-    sender = (opts['from'] or ui.config('email', 'from') or
-              ui.config('patchbomb', 'from') or
-              prompt('From', ui.username()))
-
-    def getaddrs(opt, prpt, default = None):
-        addrs = opts[opt] or (ui.config('email', opt) or
-                              ui.config('patchbomb', opt) or
-                              prompt(prpt, default = default)).split(',')
-        return [a.strip() for a in addrs if a.strip()]
-
-    to = getaddrs('to', 'To')
-    cc = getaddrs('cc', 'Cc', '')
-
-    bcc = opts['bcc'] or (ui.config('email', 'bcc') or
-                          ui.config('patchbomb', 'bcc') or '').split(',')
-    bcc = [a.strip() for a in bcc if a.strip()]
-
     def getexportmsgs():
         patches = []
 
@@ -344,6 +327,23 @@ def patchbomb(ui, repo, *revs, **opts):
     else:
         msgs = getexportmsgs()
 
+    sender = (opts['from'] or ui.config('email', 'from') or
+              ui.config('patchbomb', 'from') or
+              prompt('From', ui.username()))
+
+    def getaddrs(opt, prpt, default = None):
+        addrs = opts[opt] or (ui.config('email', opt) or
+                              ui.config('patchbomb', opt) or
+                              prompt(prpt, default = default)).split(',')
+        return [a.strip() for a in addrs if a.strip()]
+
+    to = getaddrs('to', 'To')
+    cc = getaddrs('cc', 'Cc', '')
+
+    bcc = opts['bcc'] or (ui.config('email', 'bcc') or
+                          ui.config('patchbomb', 'bcc') or '').split(',')
+    bcc = [a.strip() for a in bcc if a.strip()]
+
     ui.write('\n')
 
     if not opts['test'] and not opts['mbox']: