comparison hgext/patchbomb.py @ 2705:030d0abdf91b

merge with crew.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 27 Jul 2006 12:36:17 -0700
parents 99e7cf6bd2f7 f1de91be1d87
children 4af7b178976a
comparison
equal deleted inserted replaced
2704:99e7cf6bd2f7 2705:030d0abdf91b
36 # 36 #
37 # [email] 37 # [email]
38 # from = My Name <my@email> 38 # from = My Name <my@email>
39 # to = recipient1, recipient2, ... 39 # to = recipient1, recipient2, ...
40 # cc = cc1, cc2, ... 40 # cc = cc1, cc2, ...
41 # bcc = bcc1, bcc2, ...
41 42
42 from mercurial.demandload import * 43 from mercurial.demandload import *
43 demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils 44 demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils
44 mercurial:commands,hg,ui 45 mercurial:commands,hg,ui
45 os errno popen2 socket sys tempfile time''') 46 os errno popen2 socket sys tempfile time''')
183 prompt(prpt, default = default)).split(',') 184 prompt(prpt, default = default)).split(',')
184 return [a.strip() for a in addrs if a.strip()] 185 return [a.strip() for a in addrs if a.strip()]
185 to = getaddrs('to', 'To') 186 to = getaddrs('to', 'To')
186 cc = getaddrs('cc', 'Cc', '') 187 cc = getaddrs('cc', 'Cc', '')
187 188
189 bcc = opts['bcc'] or (ui.config('email', 'bcc') or
190 ui.config('patchbomb', 'bcc') or '').split(',')
191 bcc = [a.strip() for a in bcc if a.strip()]
192
188 if len(patches) > 1: 193 if len(patches) > 1:
189 ui.write(_('\nWrite the introductory message for the patch series.\n\n')) 194 ui.write(_('\nWrite the introductory message for the patch series.\n\n'))
190 195
191 subj = '[PATCH 0 of %d] %s' % ( 196 subj = '[PATCH 0 of %d] %s' % (
192 len(patches), 197 len(patches),
240 m['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(start_time)) + ' ' + offset 245 m['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(start_time)) + ' ' + offset
241 246
242 start_time += 1 247 start_time += 1
243 m['From'] = sender 248 m['From'] = sender
244 m['To'] = ', '.join(to) 249 m['To'] = ', '.join(to)
245 if cc: m['Cc'] = ', '.join(cc) 250 if cc: m['Cc'] = ', '.join(cc)
251 if bcc: m['Bcc'] = ', '.join(bcc)
246 if opts['test']: 252 if opts['test']:
247 ui.status('Displaying ', m['Subject'], ' ...\n') 253 ui.status('Displaying ', m['Subject'], ' ...\n')
248 fp = os.popen(os.getenv('PAGER', 'more'), 'w') 254 fp = os.popen(os.getenv('PAGER', 'more'), 'w')
249 try: 255 try:
250 fp.write(m.as_string(0)) 256 fp.write(m.as_string(0))
261 fp.write(m.as_string(0)) 267 fp.write(m.as_string(0))
262 fp.write('\n\n') 268 fp.write('\n\n')
263 fp.close() 269 fp.close()
264 else: 270 else:
265 ui.status('Sending ', m['Subject'], ' ...\n') 271 ui.status('Sending ', m['Subject'], ' ...\n')
266 mail.sendmail(sender, to + cc, m.as_string(0)) 272 mail.sendmail(sender, to + bcc + cc, m.as_string(0))
267 273
268 cmdtable = { 274 cmdtable = {
269 'email': 275 'email':
270 (patchbomb, 276 (patchbomb,
271 [('c', 'cc', [], 'email addresses of copy recipients'), 277 [('', 'bcc', [], 'email addresses of blind copy recipients'),
278 ('c', 'cc', [], 'email addresses of copy recipients'),
272 ('d', 'diffstat', None, 'add diffstat output to messages'), 279 ('d', 'diffstat', None, 'add diffstat output to messages'),
273 ('f', 'from', '', 'email address of sender'), 280 ('f', 'from', '', 'email address of sender'),
274 ('', 'plain', None, 'omit hg patch header'), 281 ('', 'plain', None, 'omit hg patch header'),
275 ('n', 'test', None, 'print messages that would be sent'), 282 ('n', 'test', None, 'print messages that would be sent'),
276 ('m', 'mbox', '', 'write messages to mbox file instead of sending them'), 283 ('m', 'mbox', '', 'write messages to mbox file instead of sending them'),