15 from email.mime.text import MIMEText |
15 from email.mime.text import MIMEText |
16 |
16 |
17 |
17 |
18 state = {'new': 'new', 'fixed': ['fixed', 'resolved']} |
18 state = {'new': 'new', 'fixed': ['fixed', 'resolved']} |
19 state['default'] = state['new'] |
19 state['default'] = state['new'] |
20 issues_dir = ".issues" |
20 default_issues_dir = ".issues" |
21 filter_prefix = ".filter" |
21 filter_prefix = ".filter" |
22 date_format = '%a, %d %b %Y %H:%M:%S' |
22 date_format = '%a, %d %b %Y %H:%M:%S' |
23 maildir_dirs = ['new','cur','tmp'] |
23 maildir_dirs = ['new','cur','tmp'] |
24 |
24 |
25 |
25 |
32 match_date, date_match = False, lambda x: True |
32 match_date, date_match = False, lambda x: True |
33 if opts['date']: |
33 if opts['date']: |
34 match_date, date_match = True, util.matchdate(opts['date']) |
34 match_date, date_match = True, util.matchdate(opts['date']) |
35 |
35 |
36 # Find issues |
36 # Find issues |
|
37 issues_dir = ui.config('artemis', 'issues', default = default_issues_dir) |
37 issues_path = os.path.join(repo.root, issues_dir) |
38 issues_path = os.path.join(repo.root, issues_dir) |
38 if not os.path.exists(issues_path): return |
39 if not os.path.exists(issues_path): return |
39 |
40 |
40 issues = glob.glob(os.path.join(issues_path, '*')) |
41 issues = glob.glob(os.path.join(issues_path, '*')) |
41 |
42 |
89 """Adds a new issue, or comment to an existing issue ID or its comment COMMENT""" |
90 """Adds a new issue, or comment to an existing issue ID or its comment COMMENT""" |
90 |
91 |
91 comment = int(comment) |
92 comment = int(comment) |
92 |
93 |
93 # First, make sure issues have a directory |
94 # First, make sure issues have a directory |
|
95 issues_dir = ui.config('artemis', 'issues', default = default_issues_dir) |
94 issues_path = os.path.join(repo.root, issues_dir) |
96 issues_path = os.path.join(repo.root, issues_dir) |
95 if not os.path.exists(issues_path): os.mkdir(issues_path) |
97 if not os.path.exists(issues_path): os.mkdir(issues_path) |
96 |
98 |
97 if id: |
99 if id: |
98 issue_fn, issue_id = _find_issue(ui, repo, id) |
100 issue_fn, issue_id = _find_issue(ui, repo, id) |
185 |
187 |
186 comment = int(comment) |
188 comment = int(comment) |
187 issue, id = _find_issue(ui, repo, id) |
189 issue, id = _find_issue(ui, repo, id) |
188 if not issue: return |
190 if not issue: return |
189 |
191 |
|
192 issues_dir = ui.config('artemis', 'issues', default = default_issues_dir) |
190 _create_missing_dirs(os.path.join(repo.root, issues_dir), issue) |
193 _create_missing_dirs(os.path.join(repo.root, issues_dir), issue) |
191 |
194 |
192 mbox = mailbox.Maildir(issue, factory=mailbox.MaildirMessage) |
195 mbox = mailbox.Maildir(issue, factory=mailbox.MaildirMessage) |
193 |
196 |
194 if opts['all']: |
197 if opts['all']: |
222 fp.close() |
225 fp.close() |
223 counter += 1 |
226 counter += 1 |
224 |
227 |
225 |
228 |
226 def _find_issue(ui, repo, id): |
229 def _find_issue(ui, repo, id): |
|
230 issues_dir = ui.config('artemis', 'issues', default = default_issues_dir) |
227 issues_path = os.path.join(repo.root, issues_dir) |
231 issues_path = os.path.join(repo.root, issues_dir) |
228 if not os.path.exists(issues_path): return False |
232 if not os.path.exists(issues_path): return False |
229 |
233 |
230 issues = glob.glob(os.path.join(issues_path, id + '*')) |
234 issues = glob.glob(os.path.join(issues_path, id + '*')) |
231 |
235 |
387 [('a', 'all', False, |
391 [('a', 'all', False, |
388 'list all issues (by default only those with state new)'), |
392 'list all issues (by default only those with state new)'), |
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*)' % (default_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', [], |