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) |
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: return |
189 |
189 |
190 _create_missing_dirs(os.path.join(repo.root, issues_dir), issue) |
190 _create_missing_dirs(os.path.join(repo.root, issues_dir), issue) |
191 |
191 |
192 mbox = mailbox.Maildir(issue, factory=mailbox.MaildirMessage) |
192 mbox = mailbox.Maildir(issue, factory=mailbox.MaildirMessage) |
193 |
193 |
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, skip = opts['skip']) |
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 |
389 ('p', 'property', [], |
389 ('p', 'property', [], |
390 'list issues with specific field values (e.g., -p state=fixed); lists all possible values of a property if no = sign'), |
390 '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)"'), |
391 ('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))], |
392 ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s*)' % (issues_dir, filter_prefix))], |
393 _('hg ilist [OPTIONS]')), |
393 _('hg ilist [OPTIONS]')), |
394 'iadd': (iadd, |
394 'iadd': (iadd, |
395 [('a', 'attach', [], |
395 [('a', 'attach', [], |
396 'attach file(s) (e.g., -a filename1 -a filename2)'), |
396 'attach file(s) (e.g., -a filename1 -a filename2)'), |
397 ('p', 'property', [], |
397 ('p', 'property', [], |
398 'update properties (e.g., -p state=fixed)'), |
398 'update properties (e.g., -p state=fixed)'), |
399 ('n', 'no-property-comment', None, |
399 ('n', 'no-property-comment', None, |
400 'do not add a comment about changed properties')], |
400 'do not add a comment about changed properties')], |
401 _('hg iadd [OPTIONS] [ID] [COMMENT]')), |
401 _('hg iadd [OPTIONS] [ID] [COMMENT]')), |
402 'ishow': (ishow, |
402 'ishow': (ishow, |
403 [('a', 'all', None, 'list all comments'), |
403 [('a', 'all', None, 'list all comments'), |
404 ('s', 'skip', '>', 'skip lines starting with a substring'), |
404 ('s', 'skip', '>', 'skip lines starting with a substring'), |
405 ('x', 'extract', [], 'extract attachments (provide attachment number as argument)')], |
405 ('x', 'extract', [], 'extract attachments (provide attachment number as argument)')], |