Patchwork patchbomb: treat address of "none" as no addresses

login
register
mail settings
Submitter Bryan O'Sullivan
Date Jan. 5, 2016, 5:56 a.m.
Message ID <5f9f47b07d59c1c86936.1451973377@bryano-mbp.local>
Download mbox | patch
Permalink /patch/12521/
State Superseded
Delegated to: Yuya Nishihara
Headers show

Comments

Bryan O'Sullivan - Jan. 5, 2016, 5:56 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# Date 1451973286 28800
#      Mon Jan 04 21:54:46 2016 -0800
# Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
# Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
patchbomb: treat address of "none" as no addresses

Previously it wasn't possible to use configuration to avoid
being prompted for e.g. a CC list when using patchbomb to send
emails.
Sean Farley - Jan. 5, 2016, 8:11 a.m.
Bryan O'Sullivan <bos@serpentine.com> writes:

> # HG changeset patch
> # User Bryan O'Sullivan <bos@serpentine.com>
> # Date 1451973286 28800
> #      Mon Jan 04 21:54:46 2016 -0800
> # Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
> # Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
> patchbomb: treat address of "none" as no addresses
>
> Previously it wasn't possible to use configuration to avoid
> being prompted for e.g. a CC list when using patchbomb to send
> emails.

Ah, yes, yes, thank you.
Yuya Nishihara - Jan. 5, 2016, 3:23 p.m.
On Mon, 04 Jan 2016 21:56:17 -0800, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bos@serpentine.com>
> # Date 1451973286 28800
> #      Mon Jan 04 21:54:46 2016 -0800
> # Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
> # Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
> patchbomb: treat address of "none" as no addresses
> 
> Previously it wasn't possible to use configuration to avoid
> being prompted for e.g. a CC list when using patchbomb to send
> emails.
> 
> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
> --- a/hgext/patchbomb.py
> +++ b/hgext/patchbomb.py
> @@ -35,7 +35,14 @@ configuration file::
>  Use ``[patchbomb]`` as configuration section name if you need to
>  override global ``[email]`` address settings.
>  
> -Then you can use the :hg:`email` command to mail a series of
> +To indicate no email addresses in the ``to`` or ``cc`` field, use
> +``none``::
> +
> +  [email]
> +  to = some-list@example.org
> +  cc = none

"none" can be a username, so it can be a valid local email address in theory.
Augie Fackler - Jan. 5, 2016, 5:47 p.m.
> On Jan 5, 2016, at 10:23 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> On Mon, 04 Jan 2016 21:56:17 -0800, Bryan O'Sullivan wrote:
>> # HG changeset patch
>> # User Bryan O'Sullivan <bos@serpentine.com>
>> # Date 1451973286 28800
>> #      Mon Jan 04 21:54:46 2016 -0800
>> # Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
>> # Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
>> patchbomb: treat address of "none" as no addresses
>> 
>> Previously it wasn't possible to use configuration to avoid
>> being prompted for e.g. a CC list when using patchbomb to send
>> emails.
>> 
>> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
>> --- a/hgext/patchbomb.py
>> +++ b/hgext/patchbomb.py
>> @@ -35,7 +35,14 @@ configuration file::
>> Use ``[patchbomb]`` as configuration section name if you need to
>> override global ``[email]`` address settings.
>> 
>> -Then you can use the :hg:`email` command to mail a series of
>> +To indicate no email addresses in the ``to`` or ``cc`` field, use
>> +``none``::
>> +
>> +  [email]
>> +  to = some-list@example.org
>> +  cc = none
> 
> "none" can be a username, so it can be a valid local email address in theory.

I’m not inclined to worry about that. In theory people could use the full @host form instead?

(I literally can’t remember I sent email without an @domain and had it arrive, though I know I used to.)

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Bryan O'Sullivan - Jan. 5, 2016, 5:50 p.m.
On Tue, Jan 5, 2016 at 7:23 AM, Yuya Nishihara <yuya@tcha.org> wrote:

> "none" can be a username, so it can be a valid local email address in
> theory.
>
>
While that is true, I don't think we should care :)  When the hypothetical
entity shows up in a billion years who actually needs that, they can always
use non@localhost or something.
Yuya Nishihara - Jan. 6, 2016, 1:16 p.m.
On Tue, 5 Jan 2016 12:47:16 -0500, Augie Fackler wrote:
> 
> > On Jan 5, 2016, at 10:23 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> > 
> > On Mon, 04 Jan 2016 21:56:17 -0800, Bryan O'Sullivan wrote:
> >> # HG changeset patch
> >> # User Bryan O'Sullivan <bos@serpentine.com>
> >> # Date 1451973286 28800
> >> #      Mon Jan 04 21:54:46 2016 -0800
> >> # Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
> >> # Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
> >> patchbomb: treat address of "none" as no addresses
> >> 
> >> Previously it wasn't possible to use configuration to avoid
> >> being prompted for e.g. a CC list when using patchbomb to send
> >> emails.
> >> 
> >> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
> >> --- a/hgext/patchbomb.py
> >> +++ b/hgext/patchbomb.py
> >> @@ -35,7 +35,14 @@ configuration file::
> >> Use ``[patchbomb]`` as configuration section name if you need to
> >> override global ``[email]`` address settings.
> >> 
> >> -Then you can use the :hg:`email` command to mail a series of
> >> +To indicate no email addresses in the ``to`` or ``cc`` field, use
> >> +``none``::
> >> +
> >> +  [email]
> >> +  to = some-list@example.org
> >> +  cc = none
> > 
> > "none" can be a username, so it can be a valid local email address in theory.
> 
> I’m not inclined to worry about that. In theory people could use the full
> @host form instead?

Yep, but people have to use the full form only for "none" user. A short form
is somewhat useful on intranet where local SMTP servers are responsible to
rewriting a login name to a full email address.

And I don't like a config value of any-text-but-x style. It's troublesome.
Sean Farley - Jan. 6, 2016, 7:52 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> On Tue, 5 Jan 2016 12:47:16 -0500, Augie Fackler wrote:
>> 
>> > On Jan 5, 2016, at 10:23 AM, Yuya Nishihara <yuya@tcha.org> wrote:
>> > 
>> > On Mon, 04 Jan 2016 21:56:17 -0800, Bryan O'Sullivan wrote:
>> >> # HG changeset patch
>> >> # User Bryan O'Sullivan <bos@serpentine.com>
>> >> # Date 1451973286 28800
>> >> #      Mon Jan 04 21:54:46 2016 -0800
>> >> # Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
>> >> # Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
>> >> patchbomb: treat address of "none" as no addresses
>> >> 
>> >> Previously it wasn't possible to use configuration to avoid
>> >> being prompted for e.g. a CC list when using patchbomb to send
>> >> emails.
>> >> 
>> >> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
>> >> --- a/hgext/patchbomb.py
>> >> +++ b/hgext/patchbomb.py
>> >> @@ -35,7 +35,14 @@ configuration file::
>> >> Use ``[patchbomb]`` as configuration section name if you need to
>> >> override global ``[email]`` address settings.
>> >> 
>> >> -Then you can use the :hg:`email` command to mail a series of
>> >> +To indicate no email addresses in the ``to`` or ``cc`` field, use
>> >> +``none``::
>> >> +
>> >> +  [email]
>> >> +  to = some-list@example.org
>> >> +  cc = none
>> > 
>> > "none" can be a username, so it can be a valid local email address in theory.
>> 
>> I’m not inclined to worry about that. In theory people could use the full
>> @host form instead?
>
> Yep, but people have to use the full form only for "none" user. A short form
> is somewhat useful on intranet where local SMTP servers are responsible to
> rewriting a login name to a full email address.
>
> And I don't like a config value of any-text-but-x style. It's troublesome.

Would it be too crazy to have:

[email]
cc =

i.e. the empty string?
Yuya Nishihara - Jan. 7, 2016, 1:30 p.m.
On Wed, 06 Jan 2016 11:52:26 -0800, Sean Farley wrote:
> Yuya Nishihara <yuya@tcha.org> writes:
> > On Tue, 5 Jan 2016 12:47:16 -0500, Augie Fackler wrote:
> >> > On Jan 5, 2016, at 10:23 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> >> > 
> >> > On Mon, 04 Jan 2016 21:56:17 -0800, Bryan O'Sullivan wrote:
> >> >> # HG changeset patch
> >> >> # User Bryan O'Sullivan <bos@serpentine.com>
> >> >> # Date 1451973286 28800
> >> >> #      Mon Jan 04 21:54:46 2016 -0800
> >> >> # Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
> >> >> # Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
> >> >> patchbomb: treat address of "none" as no addresses
> >> >> 
> >> >> Previously it wasn't possible to use configuration to avoid
> >> >> being prompted for e.g. a CC list when using patchbomb to send
> >> >> emails.
> >> >> 
> >> >> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
> >> >> --- a/hgext/patchbomb.py
> >> >> +++ b/hgext/patchbomb.py
> >> >> @@ -35,7 +35,14 @@ configuration file::
> >> >> Use ``[patchbomb]`` as configuration section name if you need to
> >> >> override global ``[email]`` address settings.
> >> >> 
> >> >> -Then you can use the :hg:`email` command to mail a series of
> >> >> +To indicate no email addresses in the ``to`` or ``cc`` field, use
> >> >> +``none``::
> >> >> +
> >> >> +  [email]
> >> >> +  to = some-list@example.org
> >> >> +  cc = none
> >> > 
> >> > "none" can be a username, so it can be a valid local email address in theory.
> >> 
> >> I’m not inclined to worry about that. In theory people could use the full
> >> @host form instead?
> >
> > Yep, but people have to use the full form only for "none" user. A short form
> > is somewhat useful on intranet where local SMTP servers are responsible to
> > rewriting a login name to a full email address.
> >
> > And I don't like a config value of any-text-but-x style. It's troublesome.
> 
> Would it be too crazy to have:
> 
> [email]
> cc =
> 
> i.e. the empty string?

It makes sense to me. Another crazy idea:

  [email]
  cc = !

"!" is obviously an invalid address, but I prefer "cc =" than "cc = !"
as "cc" takes a list of addresses.
Bryan O'Sullivan - Jan. 7, 2016, 7 p.m.
On Wed, Jan 6, 2016 at 11:52 AM, Sean Farley <sean@farley.io> wrote:

> Would it be too crazy to have:
>
> [email]
> cc =
>
> i.e. the empty string?
>

That makes sense in theory. In practice, the config API has been broken for
this kind of use basically forever: it is not possible to distinguish
between a config that doesn't exist and one that was specified as empty.
Unfortunately, this is wired in quite deeply. I've got a workaround wired
up, will send it shortly.
Pierre-Yves David - Jan. 7, 2016, 7:37 p.m.
On 01/06/2016 01:16 PM, Yuya Nishihara wrote:
> On Tue, 5 Jan 2016 12:47:16 -0500, Augie Fackler wrote:
>>
>>> On Jan 5, 2016, at 10:23 AM, Yuya Nishihara <yuya@tcha.org> wrote:
>>>
>>> On Mon, 04 Jan 2016 21:56:17 -0800, Bryan O'Sullivan wrote:
>>>> # HG changeset patch
>>>> # User Bryan O'Sullivan <bos@serpentine.com>
>>>> # Date 1451973286 28800
>>>> #      Mon Jan 04 21:54:46 2016 -0800
>>>> # Node ID 5f9f47b07d59c1c86936e4e4bdb8764f7ce3b9b0
>>>> # Parent  09ce74e1f92f8838bbcd2ac1309519f0448ffbed
>>>> patchbomb: treat address of "none" as no addresses
>>>>
>>>> Previously it wasn't possible to use configuration to avoid
>>>> being prompted for e.g. a CC list when using patchbomb to send
>>>> emails.
>>>>
>>>> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
>>>> --- a/hgext/patchbomb.py
>>>> +++ b/hgext/patchbomb.py
>>>> @@ -35,7 +35,14 @@ configuration file::
>>>> Use ``[patchbomb]`` as configuration section name if you need to
>>>> override global ``[email]`` address settings.
>>>>
>>>> -Then you can use the :hg:`email` command to mail a series of
>>>> +To indicate no email addresses in the ``to`` or ``cc`` field, use
>>>> +``none``::
>>>> +
>>>> +  [email]
>>>> +  to = some-list@example.org
>>>> +  cc = none
>>>
>>> "none" can be a username, so it can be a valid local email address in theory.
>>
>> I’m not inclined to worry about that. In theory people could use the full
>> @host form instead?
>
> Yep, but people have to use the full form only for "none" user. A short form
> is somewhat useful on intranet where local SMTP servers are responsible to
> rewriting a login name to a full email address.
>
> And I don't like a config value of any-text-but-x style. It's troublesome.


We use ! has a special value for extension. we could reuse that.

(While "!@foobar.com" is also a valid email address I'm not too concerned.
Matt Mackall - Jan. 11, 2016, 10:23 p.m.
On Thu, 2016-01-07 at 11:00 -0800, Bryan O'Sullivan wrote:
> On Wed, Jan 6, 2016 at 11:52 AM, Sean Farley <sean@farley.io> wrote:
> 
> > Would it be too crazy to have:
> > 
> > [email]
> > cc =
> > 
> > i.e. the empty string?
> > 
> 
> That makes sense in theory. In practice, the config API has been broken for
> this kind of use basically forever: it is not possible to distinguish
> between a config that doesn't exist and one that was specified as empty.

The trick is to pass in a default value of None (or some other non-string
object). If you get it back, you know it's not set.

Patch

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -35,7 +35,14 @@  configuration file::
 Use ``[patchbomb]`` as configuration section name if you need to
 override global ``[email]`` address settings.
 
-Then you can use the :hg:`email` command to mail a series of
+To indicate no email addresses in the ``to`` or ``cc`` field, use
+``none``::
+
+  [email]
+  to = some-list@example.org
+  cc = none
+
+Once configured, use the :hg:`email` command to mail a series of
 changesets as a patchbomb.
 
 You can also either configure the method option in the email section
@@ -55,6 +62,7 @@  overwritten by command line flags like -
 
 You can set patchbomb to always ask for confirmation by setting
 ``patchbomb.confirm`` to true.
+
 '''
 
 import os, errno, socket, tempfile, cStringIO
@@ -600,6 +608,8 @@  def email(ui, repo, *revs, **opts):
                 '')
         if not addr and ask:
             addr = prompt(ui, header, default=default)
+        if addr.lower() == 'none':
+            return ''
         if addr:
             showaddrs.append('%s: %s' % (header, addr))
             return mail.addrlistencode(ui, [addr], _charsets, opts.get('test'))