Show More
@@ -130,6 +130,12 b' decode/encode::' | |||||
130 | # them to the working dir |
|
130 | # them to the working dir | |
131 | **.txt = tempfile: unix2dos -n INFILE OUTFILE |
|
131 | **.txt = tempfile: unix2dos -n INFILE OUTFILE | |
132 |
|
132 | |||
|
133 | email:: | |||
|
134 | Settings for extensions that send email messages. | |||
|
135 | from;; | |||
|
136 | Optional. Email address to use in "From" header and SMTP envelope | |||
|
137 | of outgoing messages. | |||
|
138 | ||||
133 | hooks:: |
|
139 | hooks:: | |
134 | Commands or Python functions that get automatically executed by |
|
140 | Commands or Python functions that get automatically executed by | |
135 | various actions such as starting or finishing a commit. Multiple |
|
141 | various actions such as starting or finishing a commit. Multiple | |
@@ -240,6 +246,24 b' http_proxy::' | |||||
240 | user;; |
|
246 | user;; | |
241 | Optional. User name to authenticate with at the proxy server. |
|
247 | Optional. User name to authenticate with at the proxy server. | |
242 |
|
248 | |||
|
249 | smtp:: | |||
|
250 | Configuration for extensions that need to send email messages. | |||
|
251 | host;; | |||
|
252 | Optional. Host name of mail server. Default: "mail". | |||
|
253 | port;; | |||
|
254 | Optional. Port to connect to on mail server. Default: 25. | |||
|
255 | tls;; | |||
|
256 | Optional. Whether to connect to mail server using TLS. True or | |||
|
257 | False. Default: False. | |||
|
258 | username;; | |||
|
259 | Optional. User name to authenticate to SMTP server with. | |||
|
260 | If username is specified, password must also be specified. | |||
|
261 | Default: none. | |||
|
262 | password;; | |||
|
263 | Optional. Password to authenticate to SMTP server with. | |||
|
264 | If username is specified, password must also be specified. | |||
|
265 | Default: none. | |||
|
266 | ||||
243 | paths:: |
|
267 | paths:: | |
244 | Assigns symbolic names to repositories. The left side is the |
|
268 | Assigns symbolic names to repositories. The left side is the | |
245 | symbolic name, and the right gives the directory or URL that is the |
|
269 | symbolic name, and the right gives the directory or URL that is the |
@@ -31,16 +31,6 b'' | |||||
31 | # the messages directly. This can be reviewed e.g. with "mutt -R -f mbox", |
|
31 | # the messages directly. This can be reviewed e.g. with "mutt -R -f mbox", | |
32 | # and finally sent with "formail -s sendmail -bm -t < mbox". |
|
32 | # and finally sent with "formail -s sendmail -bm -t < mbox". | |
33 | # |
|
33 | # | |
34 | # To configure a default mail host, add a section like this to your |
|
|||
35 | # hgrc file: |
|
|||
36 | # |
|
|||
37 | # [smtp] |
|
|||
38 | # host = my_mail_host |
|
|||
39 | # port = 1025 |
|
|||
40 | # tls = yes # or omit if not needed |
|
|||
41 | # username = user # if SMTP authentication required |
|
|||
42 | # password = password # if SMTP authentication required - PLAINTEXT |
|
|||
43 | # |
|
|||
44 | # To configure other defaults, add a section like this to your hgrc |
|
34 | # To configure other defaults, add a section like this to your hgrc | |
45 | # file: |
|
35 | # file: | |
46 | # |
|
36 | # | |
@@ -52,7 +42,7 b'' | |||||
52 | from mercurial.demandload import * |
|
42 | from mercurial.demandload import * | |
53 | demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils |
|
43 | demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils | |
54 | mercurial:commands,hg,ui |
|
44 | mercurial:commands,hg,ui | |
55 |
os errno popen2 s |
|
45 | os errno popen2 socket sys tempfile time''') | |
56 | from mercurial.i18n import gettext as _ |
|
46 | from mercurial.i18n import gettext as _ | |
57 |
|
47 | |||
58 | try: |
|
48 | try: | |
@@ -225,17 +215,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
225 | ui.write('\n') |
|
215 | ui.write('\n') | |
226 |
|
216 | |||
227 | if not opts['test'] and not opts['mbox']: |
|
217 | if not opts['test'] and not opts['mbox']: | |
228 | s = smtplib.SMTP() |
|
218 | mail = ui.sendmail() | |
229 | s.connect(host = ui.config('smtp', 'host', 'mail'), |
|
|||
230 | port = int(ui.config('smtp', 'port', 25))) |
|
|||
231 | if ui.configbool('smtp', 'tls'): |
|
|||
232 | s.ehlo() |
|
|||
233 | s.starttls() |
|
|||
234 | s.ehlo() |
|
|||
235 | username = ui.config('smtp', 'username') |
|
|||
236 | password = ui.config('smtp', 'password') |
|
|||
237 | if username and password: |
|
|||
238 | s.login(username, password) |
|
|||
239 | parent = None |
|
219 | parent = None | |
240 | tz = time.strftime('%z') |
|
220 | tz = time.strftime('%z') | |
241 | sender_addr = email.Utils.parseaddr(sender)[1] |
|
221 | sender_addr = email.Utils.parseaddr(sender)[1] | |
@@ -273,9 +253,9 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
273 | fp.close() |
|
253 | fp.close() | |
274 | else: |
|
254 | else: | |
275 | ui.status('Sending ', m['Subject'], ' ...\n') |
|
255 | ui.status('Sending ', m['Subject'], ' ...\n') | |
276 |
|
|
256 | mail.sendmail(sender, to + cc, m.as_string(0)) | |
277 | if not opts['test'] and not opts['mbox']: |
|
257 | if not opts['test'] and not opts['mbox']: | |
278 |
|
|
258 | mail.close() | |
279 |
|
259 | |||
280 | cmdtable = { |
|
260 | cmdtable = { | |
281 | 'email': |
|
261 | 'email': |
@@ -8,7 +8,7 b'' | |||||
8 | import ConfigParser |
|
8 | import ConfigParser | |
9 | from i18n import gettext as _ |
|
9 | from i18n import gettext as _ | |
10 | from demandload import * |
|
10 | from demandload import * | |
11 | demandload(globals(), "errno os re socket sys tempfile util") |
|
11 | demandload(globals(), "errno os re smtplib socket sys tempfile util") | |
12 |
|
12 | |||
13 | class ui(object): |
|
13 | class ui(object): | |
14 | def __init__(self, verbose=False, debug=False, quiet=False, |
|
14 | def __init__(self, verbose=False, debug=False, quiet=False, | |
@@ -264,3 +264,17 b' class ui(object):' | |||||
264 | os.unlink(name) |
|
264 | os.unlink(name) | |
265 |
|
265 | |||
266 | return t |
|
266 | return t | |
|
267 | ||||
|
268 | def sendmail(self): | |||
|
269 | s = smtplib.SMTP() | |||
|
270 | s.connect(host = self.config('smtp', 'host', 'mail'), | |||
|
271 | port = int(self.config('smtp', 'port', 25))) | |||
|
272 | if self.configbool('smtp', 'tls'): | |||
|
273 | s.ehlo() | |||
|
274 | s.starttls() | |||
|
275 | s.ehlo() | |||
|
276 | username = self.config('smtp', 'username') | |||
|
277 | password = self.config('smtp', 'password') | |||
|
278 | if username and password: | |||
|
279 | s.login(username, password) | |||
|
280 | return s |
General Comments 0
You need to be logged in to leave comments.
Login now