comparison hgext/patchbomb.py @ 4479:82bc6aef8b43

patchbomb: Don't prompt for headers until sure we have revs to export. The prior behaviour was to always prompt for headers, and only then bomb out if there were actually no revs to send.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 27 May 2007 13:29:04 -0700
parents a04141f51056
children 6b84c8d2f66f
comparison
equal deleted inserted replaced
4438:3900f684a150 4479:82bc6aef8b43
248 start_time = util.makedate() 248 start_time = util.makedate()
249 249
250 def genmsgid(id): 250 def genmsgid(id):
251 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn()) 251 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
252 252
253 sender = (opts['from'] or ui.config('email', 'from') or
254 ui.config('patchbomb', 'from') or
255 prompt('From', ui.username()))
256
257 def getaddrs(opt, prpt, default = None):
258 addrs = opts[opt] or (ui.config('email', opt) or
259 ui.config('patchbomb', opt) or
260 prompt(prpt, default = default)).split(',')
261 return [a.strip() for a in addrs if a.strip()]
262
263 to = getaddrs('to', 'To')
264 cc = getaddrs('cc', 'Cc', '')
265
266 bcc = opts['bcc'] or (ui.config('email', 'bcc') or
267 ui.config('patchbomb', 'bcc') or '').split(',')
268 bcc = [a.strip() for a in bcc if a.strip()]
269
270 def getexportmsgs(): 253 def getexportmsgs():
271 patches = [] 254 patches = []
272 255
273 class exportee: 256 class exportee:
274 def __init__(self, container): 257 def __init__(self, container):
341 324
342 if opts.get('bundle'): 325 if opts.get('bundle'):
343 msgs = getbundlemsgs(getbundle(dest)) 326 msgs = getbundlemsgs(getbundle(dest))
344 else: 327 else:
345 msgs = getexportmsgs() 328 msgs = getexportmsgs()
329
330 sender = (opts['from'] or ui.config('email', 'from') or
331 ui.config('patchbomb', 'from') or
332 prompt('From', ui.username()))
333
334 def getaddrs(opt, prpt, default = None):
335 addrs = opts[opt] or (ui.config('email', opt) or
336 ui.config('patchbomb', opt) or
337 prompt(prpt, default = default)).split(',')
338 return [a.strip() for a in addrs if a.strip()]
339
340 to = getaddrs('to', 'To')
341 cc = getaddrs('cc', 'Cc', '')
342
343 bcc = opts['bcc'] or (ui.config('email', 'bcc') or
344 ui.config('patchbomb', 'bcc') or '').split(',')
345 bcc = [a.strip() for a in bcc if a.strip()]
346 346
347 ui.write('\n') 347 ui.write('\n')
348 348
349 if not opts['test'] and not opts['mbox']: 349 if not opts['test'] and not opts['mbox']:
350 mailer = mail.connect(ui) 350 mailer = mail.connect(ui)