12 issues_dir = ".issues" |
12 issues_dir = ".issues" |
13 filter_filename = ".filters" |
13 filter_filename = ".filters" |
14 date_format = '%a, %d %b %Y %H:%M:%S %Z' |
14 date_format = '%a, %d %b %Y %H:%M:%S %Z' |
15 |
15 |
16 |
16 |
17 def list(ui, repo, **opts): |
17 def ilist(ui, repo, **opts): |
18 """List issues associated with the project""" |
18 """List issues associated with the project""" |
19 |
19 |
20 # Process options |
20 # Process options |
21 show_all = opts['all'] |
21 show_all = opts['all'] |
22 properties = _get_properties(opts['property']) |
22 properties = _get_properties(opts['property']) |
43 len(mbox)-1, # number of replies (-1 for self) |
43 len(mbox)-1, # number of replies (-1 for self) |
44 mbox[0]['State'], |
44 mbox[0]['State'], |
45 mbox[0]['Subject'])) |
45 mbox[0]['Subject'])) |
46 |
46 |
47 |
47 |
48 def add(ui, repo, id = None, comment = 0): |
48 def iadd(ui, repo, id = None, comment = 0): |
49 """Adds a new issue, or comment to an existing issue ID or its comment COMMENT""" |
49 """Adds a new issue, or comment to an existing issue ID or its comment COMMENT""" |
50 |
50 |
51 comment = int(comment) |
51 comment = int(comment) |
52 |
52 |
53 # First, make sure issues have a directory |
53 # First, make sure issues have a directory |
104 if not id: |
104 if not id: |
105 repo.add([issue_fn[(len(repo.root)+1):]]) # +1 for the trailing / |
105 repo.add([issue_fn[(len(repo.root)+1):]]) # +1 for the trailing / |
106 ui.status('Added new issue %s\n' % issue_id) |
106 ui.status('Added new issue %s\n' % issue_id) |
107 |
107 |
108 |
108 |
109 def show(ui, repo, id, comment = 0, **opts): |
109 def ishow(ui, repo, id, comment = 0, **opts): |
110 """Shows issue ID, or possibly its comment COMMENT""" |
110 """Shows issue ID, or possibly its comment COMMENT""" |
111 |
111 |
112 comment = int(comment) |
112 comment = int(comment) |
113 issue, id = _find_issue(ui, repo, id) |
113 issue, id = _find_issue(ui, repo, id) |
114 if not issue: return |
114 if not issue: return |
144 mbox[0] = msg |
144 mbox[0] = msg |
145 |
145 |
146 # Write down a comment about updated properties |
146 # Write down a comment about updated properties |
147 if properties and not opts['no_property_comment']: |
147 if properties and not opts['no_property_comment']: |
148 user = ui.username() |
148 user = ui.username() |
149 properties_text = "From: %s\nDate: %s\nSubject: properties changes %s\n\n%s" % (user, time.strftime(date_format), |
149 properties_text = "From: %s\nDate: %s\nSubject: properties changes (%s)\n\n%s" % \ |
150 [property for property, value in properties], |
150 (user, time.strftime(date_format), |
|
151 _pretty_list(list(set([property for property, value in properties]))), |
151 properties_text) |
152 properties_text) |
152 msg = mailbox.mboxMessage(properties_text) |
153 msg = mailbox.mboxMessage(properties_text) |
153 msg.add_header('Message-Id', "%s-%d-artemis@%s" % (id, len(mbox), socket.gethostname())) |
154 msg.add_header('Message-Id', "%s-%d-artemis@%s" % (id, len(mbox), socket.gethostname())) |
154 msg.add_header('References', mbox[0]['Message-Id']) |
155 msg.add_header('References', mbox[0]['Message-Id']) |
155 mbox.add(msg) |
156 mbox.add(msg) |
221 id_stack += (id in children and map(lambda x: (x, offset+1), reversed(children[id]))) or [] |
222 id_stack += (id in children and map(lambda x: (x, offset+1), reversed(children[id]))) or [] |
222 index, msg = messages[id] |
223 index, msg = messages[id] |
223 ui.write(' '*offset + ('%d: ' % index) + msg['Subject'] + '\n') |
224 ui.write(' '*offset + ('%d: ' % index) + msg['Subject'] + '\n') |
224 ui.write('-'*70 + '\n') |
225 ui.write('-'*70 + '\n') |
225 |
226 |
|
227 def _pretty_list(lst): |
|
228 s = '' |
|
229 for i in lst: |
|
230 s += i + ', ' |
|
231 return s[:-2] |
|
232 |
226 |
233 |
227 cmdtable = { |
234 cmdtable = { |
228 'ilist': (list, |
235 'ilist': (ilist, |
229 [('a', 'all', False, |
236 [('a', 'all', False, |
230 'list all issues (by default only those with state new)'), |
237 'list all issues (by default only those with state new)'), |
231 ('p', 'property', [], |
238 ('p', 'property', [], |
232 'list issues with specific field values (e.g., -p state=fixed)'), |
239 'list issues with specific field values (e.g., -p state=fixed)'), |
233 ('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'), |
240 ('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'), |
234 ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s)' % (issues_dir, filter_filename))], |
241 ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s)' % (issues_dir, filter_filename))], |
235 _('hg ilist [OPTIONS]')), |
242 _('hg ilist [OPTIONS]')), |
236 'iadd': (add, |
243 'iadd': (iadd, |
237 [], |
244 [], |
238 _('hg iadd [ID] [COMMENT]')), |
245 _('hg iadd [ID] [COMMENT]')), |
239 'ishow': (show, |
246 'ishow': (ishow, |
240 [('a', 'all', None, 'list all comments')], |
247 [('a', 'all', None, 'list all comments')], |
241 _('hg ishow [OPTIONS] ID [COMMENT]')), |
248 _('hg ishow [OPTIONS] ID [COMMENT]')), |
242 'iupdate': (update, |
249 'iupdate': (iupdate, |
243 [('p', 'property', [], |
250 [('p', 'property', [], |
244 'update properties (e.g., -p state=fixed)'), |
251 'update properties (e.g., -p state=fixed)'), |
245 ('n', 'no-property-comment', None, |
252 ('n', 'no-property-comment', None, |
246 'do not add a comment about changed properties')], |
253 'do not add a comment about changed properties')], |
247 _('hg iupdate [OPTIONS] ID')) |
254 _('hg iupdate [OPTIONS] ID')) |