##// END OF EJS Templates
patchbomb: extract 'makeintro' closure into its own function...
Pierre-Yves David -
r23214:563d33fc default
parent child Browse files
Show More
@@ -238,6 +238,40 b' def _getbundlemsgs(repo, sender, bundle,'
238 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
238 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
239 return [(msg, subj, None)]
239 return [(msg, subj, None)]
240
240
241 def _makeintro(repo, sender, patches, **opts):
242 """make an introduction email, asking the user for content if needed
243
244 email is returned as (subject, body, cumulative-diffstat)"""
245 ui = repo.ui
246 _charsets = mail._charsets(ui)
247 tlen = len(str(len(patches)))
248
249 flag = opts.get('flag') or ''
250 if flag:
251 flag = ' ' + ' '.join(flag)
252 prefix = '[PATCH %0*d of %d%s]' % (tlen, 0, len(patches), flag)
253
254 subj = (opts.get('subject') or
255 prompt(ui, '(optional) Subject: ', rest=prefix, default=''))
256 if not subj:
257 return None # skip intro if the user doesn't bother
258
259 subj = prefix + ' ' + subj
260
261 body = ''
262 if opts.get('diffstat'):
263 # generate a cumulative diffstat of the whole patch series
264 diffstat = patch.diffstat(sum(patches, []))
265 body = '\n' + diffstat
266 else:
267 diffstat = None
268
269 body = _getdescription(repo, body, sender, **opts)
270 msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
271 msg['Subject'] = mail.headencode(ui, subj, _charsets,
272 opts.get('test'))
273 return (msg, subj, diffstat)
274
241 emailopts = [
275 emailopts = [
242 ('', 'body', None, _('send patches as inline message text (default)')),
276 ('', 'body', None, _('send patches as inline message text (default)')),
243 ('a', 'attach', None, _('send patches as attachments')),
277 ('a', 'attach', None, _('send patches as attachments')),
@@ -421,7 +455,7 b' def patchbomb(ui, repo, *revs, **opts):'
421
455
422 # build the intro message, or skip it if the user declines
456 # build the intro message, or skip it if the user declines
423 if introwanted(opts, len(patches)):
457 if introwanted(opts, len(patches)):
424 msg = makeintro(patches)
458 msg = _makeintro(repo, sender, patches, **opts)
425 if msg:
459 if msg:
426 msgs.append(msg)
460 msgs.append(msg)
427
461
@@ -439,34 +473,6 b' def patchbomb(ui, repo, *revs, **opts):'
439
473
440 return msgs
474 return msgs
441
475
442 def makeintro(patches):
443 tlen = len(str(len(patches)))
444
445 flag = opts.get('flag') or ''
446 if flag:
447 flag = ' ' + ' '.join(flag)
448 prefix = '[PATCH %0*d of %d%s]' % (tlen, 0, len(patches), flag)
449
450 subj = (opts.get('subject') or
451 prompt(ui, '(optional) Subject: ', rest=prefix, default=''))
452 if not subj:
453 return None # skip intro if the user doesn't bother
454
455 subj = prefix + ' ' + subj
456
457 body = ''
458 if opts.get('diffstat'):
459 # generate a cumulative diffstat of the whole patch series
460 diffstat = patch.diffstat(sum(patches, []))
461 body = '\n' + diffstat
462 else:
463 diffstat = None
464
465 body = _getdescription(repo, body, sender, **opts)
466 msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
467 msg['Subject'] = mail.headencode(ui, subj, _charsets,
468 opts.get('test'))
469 return (msg, subj, diffstat)
470
476
471 sender = (opts.get('from') or ui.config('email', 'from') or
477 sender = (opts.get('from') or ui.config('email', 'from') or
472 ui.config('patchbomb', 'from') or
478 ui.config('patchbomb', 'from') or
General Comments 0
You need to be logged in to leave comments. Login now