##// END OF EJS Templates
patchbomb: pass around ui and revs that are needed for flag template...
Yuya Nishihara -
r31186:83fa357e default
parent child Browse files
Show More
@@ -135,7 +135,7 b' def introwanted(ui, opts, number):'
135 intro = 1 < number
135 intro = 1 < number
136 return intro
136 return intro
137
137
138 def _formatprefix(flags, idx, total, numbered):
138 def _formatprefix(ui, repo, rev, flags, idx, total, numbered):
139 """build prefix to patch subject"""
139 """build prefix to patch subject"""
140 flag = ' '.join(flags)
140 flag = ' '.join(flags)
141 if flag:
141 if flag:
@@ -147,7 +147,7 b' def _formatprefix(flags, idx, total, num'
147 tlen = len(str(total))
147 tlen = len(str(total))
148 return '[PATCH %0*d of %d%s]' % (tlen, idx, total, flag)
148 return '[PATCH %0*d of %d%s]' % (tlen, idx, total, flag)
149
149
150 def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered,
150 def makepatch(ui, repo, rev, patchlines, opts, _charsets, idx, total, numbered,
151 patchname=None):
151 patchname=None):
152
152
153 desc = []
153 desc = []
@@ -214,7 +214,8 b' def makepatch(ui, repo, patchlines, opts'
214 else:
214 else:
215 msg = mail.mimetextpatch(body, display=opts.get('test'))
215 msg = mail.mimetextpatch(body, display=opts.get('test'))
216
216
217 prefix = _formatprefix(opts.get('flag'), idx, total, numbered)
217 prefix = _formatprefix(ui, repo, rev, opts.get('flag'), idx, total,
218 numbered)
218 subj = desc[0].strip().rstrip('. ')
219 subj = desc[0].strip().rstrip('. ')
219 if not numbered:
220 if not numbered:
220 subj = ' '.join([prefix, opts.get('subject') or subj])
221 subj = ' '.join([prefix, opts.get('subject') or subj])
@@ -311,14 +312,16 b' def _getbundlemsgs(repo, sender, bundle,'
311 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
312 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
312 return [(msg, subj, None)]
313 return [(msg, subj, None)]
313
314
314 def _makeintro(repo, sender, patches, **opts):
315 def _makeintro(repo, sender, revs, patches, **opts):
315 """make an introduction email, asking the user for content if needed
316 """make an introduction email, asking the user for content if needed
316
317
317 email is returned as (subject, body, cumulative-diffstat)"""
318 email is returned as (subject, body, cumulative-diffstat)"""
318 ui = repo.ui
319 ui = repo.ui
319 _charsets = mail._charsets(ui)
320 _charsets = mail._charsets(ui)
320
321
321 prefix = _formatprefix(opts.get('flag'), 0, len(patches), numbered=True)
322 # use the last revision which is likely to be a bookmarked head
323 prefix = _formatprefix(ui, repo, revs.last(), opts.get('flag'),
324 0, len(patches), numbered=True)
322 subj = (opts.get('subject') or
325 subj = (opts.get('subject') or
323 prompt(ui, '(optional) Subject: ', rest=prefix, default=''))
326 prompt(ui, '(optional) Subject: ', rest=prefix, default=''))
324 if not subj:
327 if not subj:
@@ -357,7 +360,7 b' def _getpatchmsgs(repo, sender, revs, pa'
357
360
358 # build the intro message, or skip it if the user declines
361 # build the intro message, or skip it if the user declines
359 if introwanted(ui, opts, len(patches)):
362 if introwanted(ui, opts, len(patches)):
360 msg = _makeintro(repo, sender, patches, **opts)
363 msg = _makeintro(repo, sender, revs, patches, **opts)
361 if msg:
364 if msg:
362 msgs.append(msg)
365 msgs.append(msg)
363
366
@@ -366,10 +369,11 b' def _getpatchmsgs(repo, sender, revs, pa'
366
369
367 # now generate the actual patch messages
370 # now generate the actual patch messages
368 name = None
371 name = None
369 for i, p in enumerate(patches):
372 assert len(revs) == len(patches)
373 for i, (r, p) in enumerate(zip(revs, patches)):
370 if patchnames:
374 if patchnames:
371 name = patchnames[i]
375 name = patchnames[i]
372 msg = makepatch(ui, repo, p, opts, _charsets, i + 1,
376 msg = makepatch(ui, repo, r, p, opts, _charsets, i + 1,
373 len(patches), numbered, name)
377 len(patches), numbered, name)
374 msgs.append(msg)
378 msgs.append(msg)
375
379
General Comments 0
You need to be logged in to leave comments. Login now