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