112 issue_fn, issue_id = _find_issue(ui, repo, id) |
112 issue_fn, issue_id = _find_issue(ui, repo, id) |
113 if not issue_fn: |
113 if not issue_fn: |
114 ui.warn('No such issue\n') |
114 ui.warn('No such issue\n') |
115 return |
115 return |
116 _create_missing_dirs(issues_path, issue_id) |
116 _create_missing_dirs(issues_path, issue_id) |
|
117 mbox = mailbox.Maildir(issue_fn, factory=mailbox.MaildirMessage) |
|
118 keys = _order_keys_date(mbox) |
|
119 root = keys[0] |
117 |
120 |
118 user = ui.username() |
121 user = ui.username() |
119 |
122 |
120 default_issue_text = "From: %s\nDate: %s\n" % (user, util.datestr(format = date_format)) |
123 default_issue_text = "From: %s\nDate: %s\n" % (user, util.datestr(format = date_format)) |
121 if not id: |
124 if not id: |
122 default_issue_text += "State: %s\n" % default_state |
125 default_issue_text += "State: %s\n" % default_state |
123 default_issue_text += "Subject: brief description\n\n" |
126 default_issue_text += "Subject: brief description\n\n" |
|
127 else: |
|
128 subject = mbox[(comment < len(mbox) and keys[comment]) or root]['Subject'] |
|
129 if not subject.startswith('Re: '): subject = 'Re: ' + subject |
|
130 default_issue_text += "Subject: %s\n\n" % subject |
124 default_issue_text += "Detailed description." |
131 default_issue_text += "Detailed description." |
125 |
132 |
126 # Get properties, and figure out if we need an explicit comment |
133 # Get properties, and figure out if we need an explicit comment |
127 properties = _get_properties(opts['property']) |
134 properties = _get_properties(opts['property']) |
128 no_comment = id and properties and opts['no_property_comment'] |
135 no_comment = id and properties and opts['no_property_comment'] |
163 if not id: |
170 if not id: |
164 issue_fn = issues_path |
171 issue_fn = issues_path |
165 while os.path.exists(issue_fn): |
172 while os.path.exists(issue_fn): |
166 issue_id = _random_id() |
173 issue_id = _random_id() |
167 issue_fn = os.path.join(issues_path, issue_id) |
174 issue_fn = os.path.join(issues_path, issue_id) |
|
175 mbox = mailbox.Maildir(issue_fn, factory=mailbox.MaildirMessage) |
|
176 keys = _order_keys_date(mbox) |
168 # else: issue_fn already set |
177 # else: issue_fn already set |
169 |
178 |
170 # Add message to the mailbox |
179 # Add message to the mailbox |
171 mbox = mailbox.Maildir(issue_fn, factory=mailbox.MaildirMessage) |
|
172 keys = _order_keys_date(mbox) |
|
173 mbox.lock() |
180 mbox.lock() |
174 if id and comment >= len(mbox): |
181 if id and comment >= len(mbox): |
175 ui.warn('No such comment number in mailbox, commenting on the issue itself\n') |
182 ui.warn('No such comment number in mailbox, commenting on the issue itself\n') |
176 |
183 |
177 if not id: |
184 if not id: |