##// END OF EJS Templates
patchbomb: consistently use opts.get
Christian Ebert -
r5818:77775ae8 default
parent child Browse files
Show More
@@ -166,16 +166,16 b' def patchbomb(ui, repo, *revs, **opts):'
166 166 # 'Patch subject is complete summary.')
167 167 #body += '\n\n\n'
168 168
169 if opts['plain']:
169 if opts.get('plain'):
170 170 while patch and patch[0].startswith('# '):
171 171 patch.pop(0)
172 172 if patch:
173 173 patch.pop(0)
174 174 while patch and not patch[0].strip():
175 175 patch.pop(0)
176 if opts['diffstat']:
176 if opts.get('diffstat'):
177 177 body += cdiffstat('\n'.join(desc), patch) + '\n\n'
178 if opts['attach']:
178 if opts.get('attach'):
179 179 msg = email.MIMEMultipart.MIMEMultipart()
180 180 if body:
181 181 msg.attach(email.MIMEText.MIMEText(body, 'plain'))
@@ -199,7 +199,7 b' def patchbomb(ui, repo, *revs, **opts):'
199 199
200 200 subj = desc[0].strip().rstrip('. ')
201 201 if total == 1:
202 subj = '[PATCH] ' + (opts['subject'] or subj)
202 subj = '[PATCH] ' + (opts.get('subject') or subj)
203 203 else:
204 204 tlen = len(str(total))
205 205 subj = '[PATCH %0*d of %d] %s' % (tlen, idx, total, subj)
@@ -233,7 +233,7 b' def patchbomb(ui, repo, *revs, **opts):'
233 233 pass
234 234 os.rmdir(tmpdir)
235 235
236 if not (opts['test'] or opts['mbox']):
236 if not (opts.get('test') or opts.get('mbox')):
237 237 # really sending
238 238 mail.validateconfig(ui)
239 239
@@ -264,7 +264,7 b' def patchbomb(ui, repo, *revs, **opts):'
264 264
265 265 # start
266 266 if opts.get('date'):
267 start_time = util.parsedate(opts['date'])
267 start_time = util.parsedate(opts.get('date'))
268 268 else:
269 269 start_time = util.makedate()
270 270
@@ -272,8 +272,8 b' def patchbomb(ui, repo, *revs, **opts):'
272 272 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
273 273
274 274 def getdescription(body, sender):
275 if opts['desc']:
276 body = open(opts['desc']).read()
275 if opts.get('desc'):
276 body = open(opts.get('desc')).read()
277 277 else:
278 278 ui.write(_('\nWrite the introductory message for the '
279 279 'patch series.\n\n'))
@@ -316,12 +316,12 b' def patchbomb(ui, repo, *revs, **opts):'
316 316
317 317 subj = '[PATCH %0*d of %d] %s' % (
318 318 tlen, 0, len(patches),
319 opts['subject'] or
319 opts.get('subject') or
320 320 prompt('Subject:',
321 321 rest=' [PATCH %0*d of %d] ' % (tlen, 0, len(patches))))
322 322
323 323 body = ''
324 if opts['diffstat']:
324 if opts.get('diffstat'):
325 325 d = cdiffstat(_('Final summary:\n'), jumbo)
326 326 if d:
327 327 body = '\n' + d
@@ -334,7 +334,7 b' def patchbomb(ui, repo, *revs, **opts):'
334 334 return msgs
335 335
336 336 def getbundlemsgs(bundle):
337 subj = (opts['subject']
337 subj = (opts.get('subject')
338 338 or prompt('Subject:', default='A bundle for your repository'))
339 339
340 340 body = getdescription('', sender)
@@ -350,7 +350,7 b' def patchbomb(ui, repo, *revs, **opts):'
350 350 msg['Subject'] = subj
351 351 return [msg]
352 352
353 sender = (opts['from'] or ui.config('email', 'from') or
353 sender = (opts.get('from') or ui.config('email', 'from') or
354 354 ui.config('patchbomb', 'from') or
355 355 prompt('From', ui.username()))
356 356
@@ -360,7 +360,7 b' def patchbomb(ui, repo, *revs, **opts):'
360 360 msgs = getexportmsgs()
361 361
362 362 def getaddrs(opt, prpt, default = None):
363 addrs = opts[opt] or (ui.config('email', opt) or
363 addrs = opts.get(opt) or (ui.config('email', opt) or
364 364 ui.config('patchbomb', opt) or
365 365 prompt(prpt, default = default)).split(',')
366 366 return [a.strip() for a in addrs if a.strip()]
@@ -368,7 +368,7 b' def patchbomb(ui, repo, *revs, **opts):'
368 368 to = getaddrs('to', 'To')
369 369 cc = getaddrs('cc', 'Cc', '')
370 370
371 bcc = opts['bcc'] or (ui.config('email', 'bcc') or
371 bcc = opts.get('bcc') or (ui.config('email', 'bcc') or
372 372 ui.config('patchbomb', 'bcc') or '').split(',')
373 373 bcc = [a.strip() for a in bcc if a.strip()]
374 374
@@ -396,7 +396,7 b' def patchbomb(ui, repo, *revs, **opts):'
396 396 m['Cc'] = ', '.join(cc)
397 397 if bcc:
398 398 m['Bcc'] = ', '.join(bcc)
399 if opts['test']:
399 if opts.get('test'):
400 400 ui.status('Displaying ', m['Subject'], ' ...\n')
401 401 ui.flush()
402 402 if 'PAGER' in os.environ:
@@ -411,9 +411,10 b' def patchbomb(ui, repo, *revs, **opts):'
411 411 raise
412 412 if fp is not ui:
413 413 fp.close()
414 elif opts['mbox']:
414 elif opts.get('mbox'):
415 415 ui.status('Writing ', m['Subject'], ' ...\n')
416 fp = open(opts['mbox'], m.has_key('In-Reply-To') and 'ab+' or 'wb+')
416 fp = open(opts.get('mbox'),
417 m.has_key('In-Reply-To') and 'ab+' or 'wb+')
417 418 date = util.datestr(date=start_time,
418 419 format='%a %b %d %H:%M:%S %Y', timezone=False)
419 420 fp.write('From %s %s\n' % (sender_addr, date))
General Comments 0
You need to be logged in to leave comments. Login now