67 if not os.path.exists(issues_path): os.mkdir(issues_path) |
67 if not os.path.exists(issues_path): os.mkdir(issues_path) |
68 |
68 |
69 if id: |
69 if id: |
70 issue_fn, issue_id = _find_issue(ui, repo, id) |
70 issue_fn, issue_id = _find_issue(ui, repo, id) |
71 if not issue_fn: |
71 if not issue_fn: |
72 ui.warn('No such issue') |
72 ui.warn('No such issue\n') |
73 return |
73 return |
74 |
74 |
75 user = ui.username() |
75 user = ui.username() |
76 |
76 |
77 default_issue_text = "From: %s\nDate: %s\n" % (user, time.strftime(date_format)) |
77 default_issue_text = "From: %s\nDate: %s\n" % (user, time.strftime(date_format)) |
94 |
94 |
95 # Pick random filename |
95 # Pick random filename |
96 if not id: |
96 if not id: |
97 issue_fn = issues_path |
97 issue_fn = issues_path |
98 while os.path.exists(issue_fn): |
98 while os.path.exists(issue_fn): |
99 issue_id = "%x" % random.randint(2**63, 2**64-1) |
99 issue_id = _random_id() |
100 issue_fn = os.path.join(issues_path, issue_id) |
100 issue_fn = os.path.join(issues_path, issue_id) |
101 # else: issue_fn already set |
101 # else: issue_fn already set |
102 |
102 |
103 # Add message to the mailbox |
103 # Add message to the mailbox |
104 mbox = mailbox.mbox(issue_fn) |
104 mbox = mailbox.mbox(issue_fn) |
105 if id and comment not in mbox: |
105 if id and comment not in mbox: |
106 ui.warn('No such comment number in mailbox, commenting on the issue itself\n') |
106 ui.warn('No such comment number in mailbox, commenting on the issue itself\n') |
107 if not id: |
107 if not id: |
108 msg.add_header('Message-Id', "%s-0-artemis@%s" % (issue_id, socket.gethostname())) |
108 msg.add_header('Message-Id', "<%s-0-artemis@%s>" % (issue_id, socket.gethostname())) |
109 else: |
109 else: |
110 msg.add_header('Message-Id', "%s-%d-artemis@%s" % (issue_id, len(mbox), socket.gethostname())) |
110 msg.add_header('Message-Id', "<%s-%s-artemis@%s>" % (issue_id, _random_id(), socket.gethostname())) |
111 msg.add_header('References', mbox[(comment < len(mbox) and comment) or 0]['Message-Id']) |
111 msg.add_header('References', mbox[(comment < len(mbox) and comment) or 0]['Message-Id']) |
112 mbox.add(msg) |
112 mbox.add(msg) |
113 mbox.close() |
113 mbox.close() |
114 |
114 |
115 # If adding issue, add the new mailbox to the repository |
115 # If adding issue, add the new mailbox to the repository |
161 properties_text = "From: %s\nDate: %s\nSubject: properties changes (%s)\n\n%s" % \ |
161 properties_text = "From: %s\nDate: %s\nSubject: properties changes (%s)\n\n%s" % \ |
162 (user, time.strftime(date_format), |
162 (user, time.strftime(date_format), |
163 _pretty_list(list(set([property for property, value in properties]))), |
163 _pretty_list(list(set([property for property, value in properties]))), |
164 properties_text) |
164 properties_text) |
165 msg = mailbox.mboxMessage(properties_text) |
165 msg = mailbox.mboxMessage(properties_text) |
166 msg.add_header('Message-Id', "%s-%d-artemis@%s" % (id, len(mbox), socket.gethostname())) |
166 msg.add_header('Message-Id', "<%s-%s-artemis@%s>" % (id, _random_id(), socket.gethostname())) |
167 msg.add_header('References', mbox[0]['Message-Id']) |
167 msg.add_header('References', mbox[0]['Message-Id']) |
|
168 msg.set_from('artemis', True) |
168 mbox.add(msg) |
169 mbox.add(msg) |
169 mbox.flush() |
170 mbox.flush() |
170 |
171 |
171 # Show updated message |
172 # Show updated message |
172 _show_mbox(ui, mbox, 0) |
173 _show_mbox(ui, mbox, 0) |