Patchwork D7542: mail: don't complain about a multi-word email.method

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2019, 1:51 p.m.
Message ID <differential-rev-PHID-DREV-c335cuijj6vblu7fwkla-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43563/
State New
Headers show

Comments

phabricator - Dec. 2, 2019, 1:51 p.m.
jcristau created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I want to be able to set email.method to "ssh relay /usr/sbin/sendmail"
  without needing an extra trivial shell script.
  This works fine since we pass the full command to a shell, except for
  validateconfig trying to find it in $PATH.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7542

AFFECTED FILES
  mercurial/mail.py

CHANGE DETAILS




To: jcristau, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - Dec. 3, 2019, 12:54 p.m.
> +        command = procutil.shellsplit(method)
> +        if not (command and procutil.findexe(command[0])):

This condition is correct, but `command[0]` would raise IndexError if
`not command`.

Maybe we'll need a helper function that does `shellsplit()` and returns
`command[0]` or `b''`.

> -                _(b'%r specified as email transport, but not in PATH') % method
> +                _(b'%r specified as email transport, but not in PATH') % command[0]
phabricator - Dec. 3, 2019, 12:56 p.m.
yuja added a comment.


  > +        command = procutil.shellsplit(method)
  > +        if not (command and procutil.findexe(command[0])):
  
  This condition is correct, but `command[0]` would raise IndexError if
  `not command`.
  
  Maybe we'll need a helper function that does `shellsplit()` and returns
  `command[0]` or `b''`.
  
  > - _(b'%r specified as email transport, but not in PATH') % method
  >
  > +                _(b'%r specified as email transport, but not in PATH') % command[0]

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7542/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7542

To: jcristau, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - Dec. 3, 2019, 2:51 p.m.
jcristau added a comment.
jcristau planned changes to this revision.


  doh.  Right you are.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7542/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7542

To: jcristau, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -246,9 +246,10 @@ 
                 )
             )
     else:
-        if not procutil.findexe(method):
+        command = procutil.shellsplit(method)
+        if not (command and procutil.findexe(command[0])):
             raise error.Abort(
-                _(b'%r specified as email transport, but not in PATH') % method
+                _(b'%r specified as email transport, but not in PATH') % command[0]
             )