1 # Author: Dmitriy Morozov <hg@foxcub.org>, 2007 -- 2009 |
1 # Author: Dmitriy Morozov <hg@foxcub.org>, 2007 -- 2009 |
2 |
2 |
3 """A very simple and lightweight issue tracker for Mercurial.""" |
3 """A very simple and lightweight issue tracker for Mercurial.""" |
4 |
4 |
5 from mercurial import hg, util |
5 from mercurial import hg, util |
6 from mercurial.i18n import _ |
6 from mercurial.i18n import _ |
7 import os, time, random, mailbox, glob, socket, ConfigParser |
7 import os, time, random, mailbox, glob, socket, ConfigParser |
63 for property,value in properties: |
63 for property,value in properties: |
64 if value: |
64 if value: |
65 property_match = property_match and (mbox[root][property] == value) |
65 property_match = property_match and (mbox[root][property] == value) |
66 else: |
66 else: |
67 property_match = property_match and (property not in mbox[root]) |
67 property_match = property_match and (property not in mbox[root]) |
68 |
68 |
69 if not show_all and (not properties or not property_match) and (properties or mbox[root]['State'].upper() in [f.upper() for f in state['fixed']]): continue |
69 if not show_all and (not properties or not property_match) and (properties or mbox[root]['State'].upper() in [f.upper() for f in state['fixed']]): continue |
70 if match_date and not date_match(util.parsedate(mbox[root]['date'])[0]): continue |
70 if match_date and not date_match(util.parsedate(mbox[root]['date'])[0]): continue |
71 |
71 |
72 if not list_properties: |
72 if not list_properties: |
73 ui.write("%s (%3d) [%s]: %s\n" % (issue[len(issues_path)+1:], # +1 for trailing / |
73 ui.write("%s (%3d) [%s]: %s\n" % (issue[len(issues_path)+1:], # +1 for trailing / |
123 if issue.strip() == default_issue_text: |
123 if issue.strip() == default_issue_text: |
124 ui.warn('Unchanged issue text, ignoring\n') |
124 ui.warn('Unchanged issue text, ignoring\n') |
125 return |
125 return |
126 else: |
126 else: |
127 # Write down a comment about updated properties |
127 # Write down a comment about updated properties |
128 properties_subject = ', '.join(['%s=%s' % (property, value) for (property, value) in properties]) |
128 properties_subject = ', '.join(['%s=%s' % (property, value) for (property, value) in properties]) |
129 |
129 |
130 issue = "From: %s\nDate: %s\nSubject: changed properties (%s)\n" % \ |
130 issue = "From: %s\nDate: %s\nSubject: changed properties (%s)\n" % \ |
131 (user, util.datestr(format = date_format), properties_subject) |
131 (user, util.datestr(format = date_format), properties_subject) |
132 |
132 |
133 # Create the message |
133 # Create the message |
134 msg = mailbox.MaildirMessage(issue) |
134 msg = mailbox.MaildirMessage(issue) |
183 def ishow(ui, repo, id, comment = 0, **opts): |
183 def ishow(ui, repo, id, comment = 0, **opts): |
184 """Shows issue ID, or possibly its comment COMMENT""" |
184 """Shows issue ID, or possibly its comment COMMENT""" |
185 |
185 |
186 comment = int(comment) |
186 comment = int(comment) |
187 issue, id = _find_issue(ui, repo, id) |
187 issue, id = _find_issue(ui, repo, id) |
188 if not issue: return |
188 if not issue: |
189 |
189 return ui.warn('No such issue\n') |
|
190 |
190 _create_missing_dirs(os.path.join(repo.root, issues_dir), issue) |
191 _create_missing_dirs(os.path.join(repo.root, issues_dir), issue) |
|
192 |
|
193 if opts.get('mutt'): |
|
194 return util.system('mutt -R -f %s' % issue) |
191 |
195 |
192 mbox = mailbox.Maildir(issue, factory=mailbox.MaildirMessage) |
196 mbox = mailbox.Maildir(issue, factory=mailbox.MaildirMessage) |
193 |
197 |
194 if opts['all']: |
198 if opts['all']: |
195 ui.write('='*70 + '\n') |
199 ui.write('='*70 + '\n') |
196 i = 0 |
200 i = 0 |
197 keys = _order_keys_date(mbox) |
201 keys = _order_keys_date(mbox) |
198 for k in keys: |
202 for k in keys: |
199 _write_message(ui, mbox[k], i, skip = opts['skip']) |
203 _write_message(ui, mbox[k], i, skip = opts['skip']) |
200 ui.write('-'*70 + '\n') |
204 ui.write('-'*70 + '\n') |
201 i += 1 |
205 i += 1 |
202 return |
206 return |
389 ('p', 'property', [], |
393 ('p', 'property', [], |
390 'list issues with specific field values (e.g., -p state=fixed); lists all possible values of a property if no = sign'), |
394 'list issues with specific field values (e.g., -p state=fixed); lists all possible values of a property if no = sign'), |
391 ('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'), |
395 ('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'), |
392 ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s*)' % (issues_dir, filter_prefix))], |
396 ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s*)' % (issues_dir, filter_prefix))], |
393 _('hg ilist [OPTIONS]')), |
397 _('hg ilist [OPTIONS]')), |
394 'iadd': (iadd, |
398 'iadd': (iadd, |
395 [('a', 'attach', [], |
399 [('a', 'attach', [], |
396 'attach file(s) (e.g., -a filename1 -a filename2)'), |
400 'attach file(s) (e.g., -a filename1 -a filename2)'), |
397 ('p', 'property', [], |
401 ('p', 'property', [], |
398 'update properties (e.g., -p state=fixed)'), |
402 'update properties (e.g., -p state=fixed)'), |
399 ('n', 'no-property-comment', None, |
403 ('n', 'no-property-comment', None, |
400 'do not add a comment about changed properties')], |
404 'do not add a comment about changed properties')], |
401 _('hg iadd [OPTIONS] [ID] [COMMENT]')), |
405 _('hg iadd [OPTIONS] [ID] [COMMENT]')), |
402 'ishow': (ishow, |
406 'ishow': (ishow, |
403 [('a', 'all', None, 'list all comments'), |
407 [('a', 'all', None, 'list all comments'), |
404 ('s', 'skip', '>', 'skip lines starting with a substring'), |
408 ('s', 'skip', '>', 'skip lines starting with a substring'), |
405 ('x', 'extract', [], 'extract attachments (provide attachment number as argument)')], |
409 ('x', 'extract', [], 'extract attachments (provide attachment number as argument)'), |
|
410 ('', 'mutt', False, 'use mutt to show issue')], |
406 _('hg ishow [OPTIONS] ID [COMMENT]')), |
411 _('hg ishow [OPTIONS] ID [COMMENT]')), |
407 } |
412 } |
408 |
413 |
409 # vim: expandtab |
414 # vim: expandtab |