##// END OF EJS Templates
patchbomb: simplify some contorted logic and odd variable names.
Greg Ward -
r15162:d67a15b2 default
parent child Browse files
Show More
@@ -429,29 +429,28 b' def patchbomb(ui, repo, *revs, **opts):'
429
429
430 showaddrs = []
430 showaddrs = []
431
431
432 def getaddrs(opt, prpt=None, default=None):
432 def getaddrs(header, ask=False, default=None):
433 addrs = opts.get(opt.replace('-', '_'))
433 configkey = header.lower()
434 if opt != 'reply-to':
434 opt = header.replace('-', '_').lower()
435 showaddr = '%s:' % opt.capitalize()
435 addrs = opts.get(opt)
436 else:
437 showaddr = 'Reply-To:'
438
439 if addrs:
436 if addrs:
440 showaddrs.append('%s %s' % (showaddr, ', '.join(addrs)))
437 showaddrs.append('%s: %s' % (header, ', '.join(addrs)))
441 return mail.addrlistencode(ui, addrs, _charsets, opts.get('test'))
438 return mail.addrlistencode(ui, addrs, _charsets, opts.get('test'))
442
439
443 addrs = ui.config('email', opt) or ui.config('patchbomb', opt) or ''
440 # not on the command line: fallback to config and then maybe ask
444 if not addrs and prpt:
441 addr = (ui.config('email', configkey) or
445 addrs = prompt(ui, prpt, default)
442 ui.config('patchbomb', configkey) or
443 '')
444 if not addr and ask:
445 addr = prompt(ui, header, default)
446 if addr:
447 showaddrs.append('%s: %s' % (header, addr))
448 return mail.addrlistencode(ui, [addr], _charsets, opts.get('test'))
446
449
447 if addrs:
450 to = getaddrs('To', ask=True)
448 showaddrs.append('%s %s' % (showaddr, addrs))
451 cc = getaddrs('Cc', ask=True, default='')
449 return mail.addrlistencode(ui, [addrs], _charsets, opts.get('test'))
452 bcc = getaddrs('Bcc')
450
453 replyto = getaddrs('Reply-To')
451 to = getaddrs('to', 'To')
452 cc = getaddrs('cc', 'Cc', '')
453 bcc = getaddrs('bcc')
454 replyto = getaddrs('reply-to')
455
454
456 if opts.get('diffstat') or opts.get('confirm'):
455 if opts.get('diffstat') or opts.get('confirm'):
457 ui.write(_('\nFinal summary:\n\n'))
456 ui.write(_('\nFinal summary:\n\n'))
General Comments 0
You need to be logged in to leave comments. Login now