##// END OF EJS Templates
patchbomb: add linebreaks after colons (coding style)
Christian Ebert -
r5785:38cd1ce8 default
parent child Browse files
Show More
@@ -117,13 +117,17 b' def patchbomb(ui, repo, *revs, **opts):'
117 def prompt(prompt, default = None, rest = ': ', empty_ok = False):
117 def prompt(prompt, default = None, rest = ': ', empty_ok = False):
118 if not ui.interactive:
118 if not ui.interactive:
119 return default
119 return default
120 if default: prompt += ' [%s]' % default
120 if default:
121 prompt += ' [%s]' % default
121 prompt += rest
122 prompt += rest
122 while True:
123 while True:
123 r = ui.prompt(prompt, default=default)
124 r = ui.prompt(prompt, default=default)
124 if r: return r
125 if r:
125 if default is not None: return default
126 return r
126 if empty_ok: return r
127 if default is not None:
128 return default
129 if empty_ok:
130 return r
127 ui.warn(_('Please enter a valid value.\n'))
131 ui.warn(_('Please enter a valid value.\n'))
128
132
129 def confirm(s, denial):
133 def confirm(s, denial):
@@ -149,27 +153,33 b' def patchbomb(ui, repo, *revs, **opts):'
149 body = ''
153 body = ''
150 for line in patch:
154 for line in patch:
151 if line.startswith('#'):
155 if line.startswith('#'):
152 if line.startswith('# Node ID'): node = line.split()[-1]
156 if line.startswith('# Node ID'):
157 node = line.split()[-1]
153 continue
158 continue
154 if (line.startswith('diff -r')
159 if (line.startswith('diff -r')
155 or line.startswith('diff --git')):
160 or line.startswith('diff --git')):
156 break
161 break
157 desc.append(line)
162 desc.append(line)
158 if not node: raise ValueError
163 if not node:
164 raise ValueError
159
165
160 #body = ('\n'.join(desc[1:]).strip() or
166 #body = ('\n'.join(desc[1:]).strip() or
161 # 'Patch subject is complete summary.')
167 # 'Patch subject is complete summary.')
162 #body += '\n\n\n'
168 #body += '\n\n\n'
163
169
164 if opts['plain']:
170 if opts['plain']:
165 while patch and patch[0].startswith('# '): patch.pop(0)
171 while patch and patch[0].startswith('# '):
166 if patch: patch.pop(0)
172 patch.pop(0)
167 while patch and not patch[0].strip(): patch.pop(0)
173 if patch:
174 patch.pop(0)
175 while patch and not patch[0].strip():
176 patch.pop(0)
168 if opts['diffstat']:
177 if opts['diffstat']:
169 body += cdiffstat('\n'.join(desc), patch) + '\n\n'
178 body += cdiffstat('\n'.join(desc), patch) + '\n\n'
170 if opts['attach']:
179 if opts['attach']:
171 msg = email.MIMEMultipart.MIMEMultipart()
180 msg = email.MIMEMultipart.MIMEMultipart()
172 if body: msg.attach(email.MIMEText.MIMEText(body, 'plain'))
181 if body:
182 msg.attach(email.MIMEText.MIMEText(body, 'plain'))
173 p = email.MIMEText.MIMEText('\n'.join(patch), 'x-patch')
183 p = email.MIMEText.MIMEText('\n'.join(patch), 'x-patch')
174 binnode = bin(node)
184 binnode = bin(node)
175 # if node is mq patch, it will have patch file name as tag
185 # if node is mq patch, it will have patch file name as tag
@@ -315,7 +325,8 b' def patchbomb(ui, repo, *revs, **opts):'
315 body = ''
325 body = ''
316 if opts['diffstat']:
326 if opts['diffstat']:
317 d = cdiffstat(_('Final summary:\n'), jumbo)
327 d = cdiffstat(_('Final summary:\n'), jumbo)
318 if d: body = '\n' + d
328 if d:
329 body = '\n' + d
319
330
320 body = getdescription(body, sender)
331 body = getdescription(body, sender)
321 msg = email.MIMEText.MIMEText(body)
332 msg = email.MIMEText.MIMEText(body)
@@ -383,8 +394,10 b' def patchbomb(ui, repo, *revs, **opts):'
383 start_time = (start_time[0] + 1, start_time[1])
394 start_time = (start_time[0] + 1, start_time[1])
384 m['From'] = sender
395 m['From'] = sender
385 m['To'] = ', '.join(to)
396 m['To'] = ', '.join(to)
386 if cc: m['Cc'] = ', '.join(cc)
397 if cc:
387 if bcc: m['Bcc'] = ', '.join(bcc)
398 m['Cc'] = ', '.join(cc)
399 if bcc:
400 m['Bcc'] = ', '.join(bcc)
388 if opts['test']:
401 if opts['test']:
389 ui.status('Displaying ', m['Subject'], ' ...\n')
402 ui.status('Displaying ', m['Subject'], ' ...\n')
390 ui.flush()
403 ui.flush()
General Comments 0
You need to be logged in to leave comments. Login now