##// END OF EJS Templates
patchbomb: factor out function that builds a prefix string to patch subject...
Yuya Nishihara -
r31183:8018b90f default
parent child Browse files
Show More
@@ -135,6 +135,18 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):
139 """build prefix to patch subject"""
140 flag = ' '.join(flags)
141 if flag:
142 flag = ' ' + flag
143
144 if not numbered:
145 return '[PATCH%s]' % flag
146 else:
147 tlen = len(str(total))
148 return '[PATCH %0*d of %d%s]' % (tlen, idx, total, flag)
149
138 def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered,
150 def makepatch(ui, repo, patchlines, opts, _charsets, idx, total, numbered,
139 patchname=None):
151 patchname=None):
140
152
@@ -202,16 +214,12 b' def makepatch(ui, repo, patchlines, opts'
202 else:
214 else:
203 msg = mail.mimetextpatch(body, display=opts.get('test'))
215 msg = mail.mimetextpatch(body, display=opts.get('test'))
204
216
205 flag = ' '.join(opts.get('flag'))
217 prefix = _formatprefix(opts.get('flag'), idx, total, numbered)
206 if flag:
207 flag = ' ' + flag
208
209 subj = desc[0].strip().rstrip('. ')
218 subj = desc[0].strip().rstrip('. ')
210 if not numbered:
219 if not numbered:
211 subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj)
220 subj = ' '.join([prefix, opts.get('subject') or subj])
212 else:
221 else:
213 tlen = len(str(total))
222 subj = ' '.join([prefix, subj])
214 subj = '[PATCH %0*d of %d%s] %s' % (tlen, idx, total, flag, subj)
215 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
223 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
216 msg['X-Mercurial-Node'] = node
224 msg['X-Mercurial-Node'] = node
217 msg['X-Mercurial-Series-Index'] = '%i' % idx
225 msg['X-Mercurial-Series-Index'] = '%i' % idx
@@ -309,13 +317,8 b' def _makeintro(repo, sender, patches, **'
309 email is returned as (subject, body, cumulative-diffstat)"""
317 email is returned as (subject, body, cumulative-diffstat)"""
310 ui = repo.ui
318 ui = repo.ui
311 _charsets = mail._charsets(ui)
319 _charsets = mail._charsets(ui)
312 tlen = len(str(len(patches)))
313
320
314 flag = opts.get('flag') or ''
321 prefix = _formatprefix(opts.get('flag'), 0, len(patches), numbered=True)
315 if flag:
316 flag = ' ' + ' '.join(flag)
317 prefix = '[PATCH %0*d of %d%s]' % (tlen, 0, len(patches), flag)
318
319 subj = (opts.get('subject') or
322 subj = (opts.get('subject') or
320 prompt(ui, '(optional) Subject: ', rest=prefix, default=''))
323 prompt(ui, '(optional) Subject: ', rest=prefix, default=''))
321 if not subj:
324 if not subj:
General Comments 0
You need to be logged in to leave comments. Login now