Show More
@@ -45,7 +45,7 b' directly from the commandline. See the [' | |||
|
45 | 45 | hgrc(5) for details. |
|
46 | 46 | ''' |
|
47 | 47 | |
|
48 |
import os, errno, socket, tempfile, cStringIO |
|
|
48 | import os, errno, socket, tempfile, cStringIO | |
|
49 | 49 | import email.MIMEMultipart, email.MIMEBase |
|
50 | 50 | import email.Utils, email.Encoders, email.Generator |
|
51 | 51 | from mercurial import cmdutil, commands, hg, mail, patch, util, discovery |
@@ -532,23 +532,12 b' def patchbomb(ui, repo, *revs, **opts):' | |||
|
532 | 532 | raise |
|
533 | 533 | if fp is not ui: |
|
534 | 534 | fp.close() |
|
535 |
el |
|
|
535 | else: | |
|
536 | if not sendmail: | |
|
537 | sendmail = mail.connect(ui, mbox=mbox) | |
|
536 | 538 | ui.status(_('Sending '), subj, ' ...\n') |
|
537 | 539 | ui.progress(_('sending'), i, item=subj, total=len(msgs)) |
|
538 | fp = open(mbox, i > 0 and 'ab+' or 'wb+') | |
|
539 | generator = email.Generator.Generator(fp, mangle_from_=True) | |
|
540 | # Should be time.asctime(), but Windows prints 2-characters day | |
|
541 | # of month instead of one. Make them print the same thing. | |
|
542 | date = time.strftime('%a %b %d %H:%M:%S %Y', time.localtime()) | |
|
543 | fp.write('From %s %s\n' % (sender_addr, date)) | |
|
544 | generator.flatten(m, 0) | |
|
545 | fp.write('\n\n') | |
|
546 | fp.close() | |
|
547 | else: | |
|
548 | if not sendmail: | |
|
549 | sendmail = mail.connect(ui) | |
|
550 | ui.status(_('Sending '), subj, ' ...\n') | |
|
551 | ui.progress(_('sending'), i, item=subj, total=len(msgs)) | |
|
540 | if not mbox: | |
|
552 | 541 | # Exim does not remove the Bcc field |
|
553 | 542 | del m['Bcc'] |
|
554 | 543 | fp = cStringIO.StringIO() |
@@ -7,7 +7,7 b'' | |||
|
7 | 7 | |
|
8 | 8 | from i18n import _ |
|
9 | 9 | import util, encoding |
|
10 | import os, smtplib, socket, quopri | |
|
10 | import os, smtplib, socket, quopri, time | |
|
11 | 11 | import email.Header, email.MIMEText, email.Utils |
|
12 | 12 | |
|
13 | 13 | _oldheaderinit = email.Header.Header.__init__ |
@@ -93,9 +93,23 b' def _sendmail(ui, sender, recipients, ms' | |||
|
93 | 93 | os.path.basename(program.split(None, 1)[0]), |
|
94 | 94 | util.explainexit(ret)[0])) |
|
95 | 95 | |
|
96 | def connect(ui): | |
|
96 | def _mbox(mbox, sender, recipients, msg): | |
|
97 | '''write mails to mbox''' | |
|
98 | fp = open(mbox, 'ab+') | |
|
99 | # Should be time.asctime(), but Windows prints 2-characters day | |
|
100 | # of month instead of one. Make them print the same thing. | |
|
101 | date = time.strftime('%a %b %d %H:%M:%S %Y', time.localtime()) | |
|
102 | fp.write('From %s %s\n' % (sender, date)) | |
|
103 | fp.write(msg) | |
|
104 | fp.write('\n\n') | |
|
105 | fp.close() | |
|
106 | ||
|
107 | def connect(ui, mbox=None): | |
|
97 | 108 | '''make a mail connection. return a function to send mail. |
|
98 | 109 | call as sendmail(sender, list-of-recipients, msg).''' |
|
110 | if mbox: | |
|
111 | open(mbox, 'wb').close() | |
|
112 | return lambda s, r, m: _mbox(mbox, s, r, m) | |
|
99 | 113 | if ui.config('email', 'method', 'smtp') == 'smtp': |
|
100 | 114 | return _smtp(ui) |
|
101 | 115 | return lambda s, r, m: _sendmail(ui, s, r, m) |
General Comments 0
You need to be logged in to leave comments.
Login now