194 if opts['all']: |
194 if opts['all']: |
195 ui.write('='*70 + '\n') |
195 ui.write('='*70 + '\n') |
196 i = 0 |
196 i = 0 |
197 keys = _order_keys_date(mbox) |
197 keys = _order_keys_date(mbox) |
198 for k in keys: |
198 for k in keys: |
199 _write_message(ui, mbox[k], i) |
199 _write_message(ui, mbox[k], i, skip = opts['skip']) |
200 ui.write('-'*70 + '\n') |
200 ui.write('-'*70 + '\n') |
201 i += 1 |
201 i += 1 |
202 return |
202 return |
203 |
203 |
204 _show_mbox(ui, mbox, comment) |
204 _show_mbox(ui, mbox, comment, skip = opts['skip']) |
205 |
205 |
206 if opts['extract']: |
206 if opts['extract']: |
207 attachment_numbers = map(int, opts['extract']) |
207 attachment_numbers = map(int, opts['extract']) |
208 keys = _order_keys_date(mbox) |
208 keys = _order_keys_date(mbox) |
209 msg = mbox[keys[comment]] |
209 msg = mbox[keys[comment]] |
239 return issues[0], issues[0][len(issues_path)+1:] |
239 return issues[0], issues[0][len(issues_path)+1:] |
240 |
240 |
241 def _get_properties(property_list): |
241 def _get_properties(property_list): |
242 return [p.split('=') for p in property_list] |
242 return [p.split('=') for p in property_list] |
243 |
243 |
244 def _write_message(ui, message, index = 0): |
244 def _write_message(ui, message, index = 0, skip = None): |
245 if index: ui.write("Comment: %d\n" % index) |
245 if index: ui.write("Comment: %d\n" % index) |
246 if ui.verbose: |
246 if ui.verbose: |
247 ui.write(message.as_string().strip() + '\n') |
247 _show_text(ui, message.as_string().strip(), skip) |
248 else: |
248 else: |
249 if 'From' in message: ui.write('From: %s\n' % message['From']) |
249 if 'From' in message: ui.write('From: %s\n' % message['From']) |
250 if 'Date' in message: ui.write('Date: %s\n' % message['Date']) |
250 if 'Date' in message: ui.write('Date: %s\n' % message['Date']) |
251 if 'Subject' in message: ui.write('Subject: %s\n' % message['Subject']) |
251 if 'Subject' in message: ui.write('Subject: %s\n' % message['Subject']) |
252 if 'State' in message: ui.write('State: %s\n' % message['State']) |
252 if 'State' in message: ui.write('State: %s\n' % message['State']) |
254 for part in message.walk(): |
254 for part in message.walk(): |
255 ctype = part.get_content_type() |
255 ctype = part.get_content_type() |
256 maintype, subtype = ctype.split('/', 1) |
256 maintype, subtype = ctype.split('/', 1) |
257 if maintype == 'multipart': continue |
257 if maintype == 'multipart': continue |
258 if ctype == 'text/plain': |
258 if ctype == 'text/plain': |
259 ui.write('\n' + part.get_payload().strip() + '\n') |
259 ui.write('\n') |
|
260 _show_text(ui, part.get_payload().strip(), skip) |
260 else: |
261 else: |
261 filename = part.get_filename() |
262 filename = part.get_filename() |
262 ui.write('\n' + '%d: Attachment [%s, %s]: %s' % (counter, ctype, _humanreadable(len(part.get_payload())), filename) + '\n') |
263 ui.write('\n' + '%d: Attachment [%s, %s]: %s' % (counter, ctype, _humanreadable(len(part.get_payload())), filename) + '\n') |
263 counter += 1 |
264 counter += 1 |
264 |
265 |
265 def _show_mbox(ui, mbox, comment): |
266 def _show_text(ui, text, skip = None): |
|
267 for line in text.splitlines(): |
|
268 if not skip or not line.startswith(skip): |
|
269 ui.write(line + '\n') |
|
270 ui.write('\n') |
|
271 |
|
272 def _show_mbox(ui, mbox, comment, **opts): |
266 # Output the issue (or comment) |
273 # Output the issue (or comment) |
267 if comment >= len(mbox): |
274 if comment >= len(mbox): |
268 comment = 0 |
275 comment = 0 |
269 ui.warn('Comment out of range, showing the issue itself\n') |
276 ui.warn('Comment out of range, showing the issue itself\n') |
270 keys = _order_keys_date(mbox) |
277 keys = _order_keys_date(mbox) |
273 ui.write('='*70 + '\n') |
280 ui.write('='*70 + '\n') |
274 if comment: |
281 if comment: |
275 ui.write('Subject: %s\n' % mbox[root]['Subject']) |
282 ui.write('Subject: %s\n' % mbox[root]['Subject']) |
276 ui.write('State: %s\n' % mbox[root]['State']) |
283 ui.write('State: %s\n' % mbox[root]['State']) |
277 ui.write('-'*70 + '\n') |
284 ui.write('-'*70 + '\n') |
278 _write_message(ui, msg, comment) |
285 _write_message(ui, msg, comment, skip = ('skip' in opts) and opts['skip']) |
279 ui.write('-'*70 + '\n') |
286 ui.write('-'*70 + '\n') |
280 |
287 |
281 # Read the mailbox into the messages and children dictionaries |
288 # Read the mailbox into the messages and children dictionaries |
282 messages = {} |
289 messages = {} |
283 children = {} |
290 children = {} |
392 ('n', 'no-property-comment', None, |
399 ('n', 'no-property-comment', None, |
393 'do not add a comment about changed properties')], |
400 'do not add a comment about changed properties')], |
394 _('hg iadd [OPTIONS] [ID] [COMMENT]')), |
401 _('hg iadd [OPTIONS] [ID] [COMMENT]')), |
395 'ishow': (ishow, |
402 'ishow': (ishow, |
396 [('a', 'all', None, 'list all comments'), |
403 [('a', 'all', None, 'list all comments'), |
|
404 ('s', 'skip', '>', 'skip lines starting with a substring'), |
397 ('x', 'extract', [], 'extract attachments (provide attachment number as argument)')], |
405 ('x', 'extract', [], 'extract attachments (provide attachment number as argument)')], |
398 _('hg ishow [OPTIONS] ID [COMMENT]')), |
406 _('hg ishow [OPTIONS] ID [COMMENT]')), |
399 } |
407 } |
400 |
408 |
401 # vim: expandtab |
409 # vim: expandtab |