##// END OF EJS Templates
patchbomb: extract 'getpatchmsgs' closure into its own function...
Pierre-Yves David -
r23215:83a19103 default
parent child Browse files
Show More
@@ -272,6 +272,40 b' def _makeintro(repo, sender, patches, **'
272 opts.get('test'))
272 opts.get('test'))
273 return (msg, subj, diffstat)
273 return (msg, subj, diffstat)
274
274
275 def _getpatchmsgs(repo, sender, patches, patchnames=None, **opts):
276 """return a list of emails from a list of patches
277
278 This involves introduction message creation if necessary.
279
280 This function returns a list of "email" tuples (subject, content, None).
281 """
282 ui = repo.ui
283 _charsets = mail._charsets(ui)
284 msgs = []
285
286 ui.write(_('this patch series consists of %d patches.\n\n')
287 % len(patches))
288
289 # build the intro message, or skip it if the user declines
290 if introwanted(opts, len(patches)):
291 msg = _makeintro(repo, sender, patches, **opts)
292 if msg:
293 msgs.append(msg)
294
295 # are we going to send more than one message?
296 numbered = len(msgs) + len(patches) > 1
297
298 # now generate the actual patch messages
299 name = None
300 for i, p in enumerate(patches):
301 if patchnames:
302 name = patchnames[i]
303 msg = makepatch(ui, repo, p, opts, _charsets, i + 1,
304 len(patches), numbered, name)
305 msgs.append(msg)
306
307 return msgs
308
275 emailopts = [
309 emailopts = [
276 ('', 'body', None, _('send patches as inline message text (default)')),
310 ('', 'body', None, _('send patches as inline message text (default)')),
277 ('a', 'attach', None, _('send patches as attachments')),
311 ('a', 'attach', None, _('send patches as attachments')),
@@ -447,46 +481,21 b' def patchbomb(ui, repo, *revs, **opts):'
447 def genmsgid(id):
481 def genmsgid(id):
448 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
482 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
449
483
450 def getpatchmsgs(patches, patchnames=None):
451 msgs = []
452
453 ui.write(_('this patch series consists of %d patches.\n\n')
454 % len(patches))
455
456 # build the intro message, or skip it if the user declines
457 if introwanted(opts, len(patches)):
458 msg = _makeintro(repo, sender, patches, **opts)
459 if msg:
460 msgs.append(msg)
461
462 # are we going to send more than one message?
463 numbered = len(msgs) + len(patches) > 1
464
465 # now generate the actual patch messages
466 name = None
467 for i, p in enumerate(patches):
468 if patchnames:
469 name = patchnames[i]
470 msg = makepatch(ui, repo, p, opts, _charsets, i + 1,
471 len(patches), numbered, name)
472 msgs.append(msg)
473
474 return msgs
475
476
477 sender = (opts.get('from') or ui.config('email', 'from') or
484 sender = (opts.get('from') or ui.config('email', 'from') or
478 ui.config('patchbomb', 'from') or
485 ui.config('patchbomb', 'from') or
479 prompt(ui, 'From', ui.username()))
486 prompt(ui, 'From', ui.username()))
480
487
481 if patches:
488 if patches:
482 msgs = getpatchmsgs(patches, opts.get('patchnames'))
489 msgs = _getpatchmsgs(repo, sender, patches, opts.get('patchnames'),
490 **opts)
483 elif bundle:
491 elif bundle:
484 bundledata = _getbundle(repo, dest, **opts)
492 bundledata = _getbundle(repo, dest, **opts)
485 bundleopts = opts.copy()
493 bundleopts = opts.copy()
486 bundleopts.pop('bundle', None) # already processed
494 bundleopts.pop('bundle', None) # already processed
487 msgs = _getbundlemsgs(repo, sender, bundledata, **bundleopts)
495 msgs = _getbundlemsgs(repo, sender, bundledata, **bundleopts)
488 else:
496 else:
489 msgs = getpatchmsgs(list(_getpatches(repo, revs, **opts)))
497 _patches = list(_getpatches(repo, revs, **opts))
498 msgs = _getpatchmsgs(repo, sender, _patches, **opts)
490
499
491 showaddrs = []
500 showaddrs = []
492
501
General Comments 0
You need to be logged in to leave comments. Login now