changeset 32826:3abba5bc3454

patchbomb: make getaddrs function easier to work with Prior to this the return value was potentially None, a string, or a list of strings. It now always returns a list of strings where each string is always only one email address
author Augie Fackler <augie@google.com>
date Tue, 13 Jun 2017 17:43:33 -0400
parents 16ff5c6066a6
children 526f9f12f707
files hgext/patchbomb.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Tue Jun 13 16:30:50 2017 -0400
+++ b/hgext/patchbomb.py	Tue Jun 13 17:43:33 2017 -0400
@@ -660,15 +660,17 @@
         if addr:
             showaddrs.append('%s: %s' % (header, addr))
             return mail.addrlistencode(ui, [addr], _charsets, opts.get('test'))
-        else:
-            return default
+        elif default:
+            return mail.addrlistencode(
+                ui, [default], _charsets, opts.get('test'))
+        return []
 
     to = getaddrs('To', ask=True)
     if not to:
         # we can get here in non-interactive mode
         raise error.Abort(_('no recipient addresses provided'))
-    cc = getaddrs('Cc', ask=True, default='') or []
-    bcc = getaddrs('Bcc') or []
+    cc = getaddrs('Cc', ask=True, default='')
+    bcc = getaddrs('Bcc')
     replyto = getaddrs('Reply-To')
 
     confirm = ui.configbool('patchbomb', 'confirm')