[PATCH] mail: fix regression introduced in dc6ed2736c81 (issue #943)

Matt Mackall mpm at selenic.com
Fri Jan 25 15:18:27 CST 2008


On Fri, 2008-01-25 at 20:57 +0000, Christian Ebert wrote:
> * Christian Ebert on Friday, January 25, 2008 at 14:01:37 +0000
> > afaics the price for giving up a class is introducing a global
> > variable, if we want to reuse an active connection via smptlib.
> 
> If we don't want a global var, and without adding an additional
> argument to all send calls, the only way I see to solve this is
> by adding a _mailer attribute to ui.
> 
> external sendmail method has no connection parameter
> smtplib methos has additional connection parameter
> 
> Here's a proposal with adding ui._mailer

Mystified. Why isn't this sufficient:

diff -r 5d81251dedae mercurial/mail.py
--- a/mercurial/mail.py	Tue Jan 22 23:07:23 2008 +0100
+++ b/mercurial/mail.py	Fri Jan 25 15:11:14 2008 -0600
@@ -56,7 +56,7 @@
     '''make a mail connection. return a function to send mail.
     call as sendmail(sender, list-of-recipients, msg).'''
 
-    func =  _sendmail
+    func = lambda s, r, m: _sendmail(ui, s, r, m)
     if ui.config('email', 'method', 'smtp') == 'smtp':
         func = _smtp(ui)
 

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list