Patchwork [3,of,5,RFC] patchbomb: make getaddrs function easier to work with

login
register
mail settings
Submitter Augie Fackler
Date June 13, 2017, 10:12 p.m.
Message ID <218470bf601bb0baaae3.1497391958@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/21363/
State Accepted
Headers show

Comments

Augie Fackler - June 13, 2017, 10:12 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1497390213 14400
#      Tue Jun 13 17:43:33 2017 -0400
# Node ID 218470bf601bb0baaae333c73ccc0aab615d8f40
# Parent  c33d1593d5d60468b0260d554311278746f50506
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
Yuya Nishihara - June 14, 2017, 2:18 p.m.
On Tue, 13 Jun 2017 18:12:38 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1497390213 14400
> #      Tue Jun 13 17:43:33 2017 -0400
> # Node ID 218470bf601bb0baaae333c73ccc0aab615d8f40
> # Parent  c33d1593d5d60468b0260d554311278746f50506
> patchbomb: make getaddrs function easier to work with

Queued up to here, thanks.

Patch

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -660,15 +660,17 @@  def email(ui, repo, *revs, **opts):
         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')