Show More
@@ -27,6 +27,10 b'' | |||||
27 | # firing it up "for real", in which case it will use your pager to |
|
27 | # firing it up "for real", in which case it will use your pager to | |
28 | # display each of the messages that it would send. |
|
28 | # display each of the messages that it would send. | |
29 | # |
|
29 | # | |
|
30 | # The "-m" (mbox) option will create an mbox file instead of sending | |||
|
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". | |||
|
33 | # | |||
30 | # To configure a default mail host, add a section like this to your |
|
34 | # To configure a default mail host, add a section like this to your | |
31 | # hgrc file: |
|
35 | # hgrc file: | |
32 | # |
|
36 | # | |
@@ -47,6 +51,7 b'' | |||||
47 |
|
51 | |||
48 | from email.MIMEMultipart import MIMEMultipart |
|
52 | from email.MIMEMultipart import MIMEMultipart | |
49 | from email.MIMEText import MIMEText |
|
53 | from email.MIMEText import MIMEText | |
|
54 | from email.Utils import parseaddr | |||
50 | from mercurial import commands |
|
55 | from mercurial import commands | |
51 | from mercurial import hg |
|
56 | from mercurial import hg | |
52 | from mercurial import ui |
|
57 | from mercurial import ui | |
@@ -222,7 +227,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
222 |
|
227 | |||
223 | msgs.insert(0, msg) |
|
228 | msgs.insert(0, msg) | |
224 |
|
229 | |||
225 | if not opts['test']: |
|
230 | if not opts['test'] and not opts['mbox']: | |
226 | s = smtplib.SMTP() |
|
231 | s = smtplib.SMTP() | |
227 | s.connect(host = ui.config('smtp', 'host', 'mail'), |
|
232 | s.connect(host = ui.config('smtp', 'host', 'mail'), | |
228 | port = int(ui.config('smtp', 'port', 25))) |
|
233 | port = int(ui.config('smtp', 'port', 25))) | |
@@ -236,6 +241,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
236 | s.login(username, password) |
|
241 | s.login(username, password) | |
237 | parent = None |
|
242 | parent = None | |
238 | tz = time.strftime('%z') |
|
243 | tz = time.strftime('%z') | |
|
244 | sender_addr = parseaddr(sender)[1] | |||
239 | for m in msgs: |
|
245 | for m in msgs: | |
240 | try: |
|
246 | try: | |
241 | m['Message-Id'] = genmsgid(m['X-Mercurial-Node']) |
|
247 | m['Message-Id'] = genmsgid(m['X-Mercurial-Node']) | |
@@ -250,15 +256,24 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
250 | m['From'] = sender |
|
256 | m['From'] = sender | |
251 | m['To'] = ', '.join(to) |
|
257 | m['To'] = ', '.join(to) | |
252 | if cc: m['Cc'] = ', '.join(cc) |
|
258 | if cc: m['Cc'] = ', '.join(cc) | |
253 | ui.status('Sending ', m['Subject'], ' ...\n') |
|
|||
254 | if opts['test']: |
|
259 | if opts['test']: | |
|
260 | ui.status('Displaying ', m['Subject'], ' ...\n') | |||
255 | fp = os.popen(os.getenv('PAGER', 'more'), 'w') |
|
261 | fp = os.popen(os.getenv('PAGER', 'more'), 'w') | |
256 | fp.write(m.as_string(0)) |
|
262 | fp.write(m.as_string(0)) | |
257 | fp.write('\n') |
|
263 | fp.write('\n') | |
258 | fp.close() |
|
264 | fp.close() | |
|
265 | elif opts['mbox']: | |||
|
266 | ui.status('Writing ', m['Subject'], ' ...\n') | |||
|
267 | fp = open(opts['mbox'], m.has_key('In-Reply-To') and 'ab+' or 'wb+') | |||
|
268 | date = time.asctime(time.localtime(start_time)) | |||
|
269 | fp.write('From %s %s\n' % (sender_addr, date)) | |||
|
270 | fp.write(m.as_string(0)) | |||
|
271 | fp.write('\n\n') | |||
|
272 | fp.close() | |||
259 | else: |
|
273 | else: | |
|
274 | ui.status('Sending ', m['Subject'], ' ...\n') | |||
260 | s.sendmail(sender, to + cc, m.as_string(0)) |
|
275 | s.sendmail(sender, to + cc, m.as_string(0)) | |
261 | if not opts['test']: |
|
276 | if not opts['test'] and not opts['mbox']: | |
262 | s.close() |
|
277 | s.close() | |
263 |
|
278 | |||
264 | cmdtable = { |
|
279 | cmdtable = { | |
@@ -269,6 +284,7 b' cmdtable = {' | |||||
269 | ('f', 'from', '', 'email address of sender'), |
|
284 | ('f', 'from', '', 'email address of sender'), | |
270 | ('', 'plain', None, 'omit hg patch header'), |
|
285 | ('', 'plain', None, 'omit hg patch header'), | |
271 | ('n', 'test', None, 'print messages that would be sent'), |
|
286 | ('n', 'test', None, 'print messages that would be sent'), | |
|
287 | ('m', 'mbox', '', 'write messages to mbox file instead of sending them'), | |||
272 | ('s', 'subject', '', 'subject of introductory message'), |
|
288 | ('s', 'subject', '', 'subject of introductory message'), | |
273 | ('t', 'to', [], 'email addresses of recipients')], |
|
289 | ('t', 'to', [], 'email addresses of recipients')], | |
274 | "hg email [OPTION]... [REV]...") |
|
290 | "hg email [OPTION]... [REV]...") |
General Comments 0
You need to be logged in to leave comments.
Login now