Merge lp:~allenap/launchpad/dont-pass-bugwatches-to-externalbugtracker into lp:launchpad
- dont-pass-bugwatches-to-externalbugtracker
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Gavin Panella |
Approved revision: | not available |
Merged at revision: | not available |
Proposed branch: | lp:~allenap/launchpad/dont-pass-bugwatches-to-externalbugtracker |
Merge into: | lp:launchpad |
Diff against target: |
612 lines (+100/-89) 9 files modified
lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt (+17/-15) lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt (+9/-8) lib/lp/bugs/doc/externalbugtracker-debbugs.txt (+9/-9) lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt (+12/-11) lib/lp/bugs/externalbugtracker/bugzilla.py (+15/-15) lib/lp/bugs/externalbugtracker/debbugs.py (+7/-7) lib/lp/bugs/externalbugtracker/trac.py (+9/-9) lib/lp/bugs/interfaces/externalbugtracker.py (+16/-11) lib/lp/bugs/scripts/checkwatches.py (+6/-4) |
To merge this branch: | bzr merge lp:~allenap/launchpad/dont-pass-bugwatches-to-externalbugtracker |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Nelson (community) | code | Approve | |
Review via email: mp+16899@code.launchpad.net |
Commit message
Pass only the remote bug ID into providers of ISupportsCommen
Description of the change
Gavin Panella (allenap) wrote : | # |
Michael Nelson (michael.nelson) wrote : | # |
G'day Gavin,
All looks very straight forward. Just one tiny comment below.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -406,7 +406,7 @@
> a given remote bug.
>
> >>> bugzilla.
> - >>> bug_comment_ids = bugzilla.
> + >>> bug_comment_ids = bugzilla.
> CALLED Bug.comments(
>
> >>> print sorted(
> @@ -415,7 +415,7 @@
> getCommentIds() can only be called if initializeRemot
> called and the bug exists locally.
>
> - >>> bugzilla.
> + >>> bugzilla.
> Traceback (most recent call last):
> ...
> BugNotFound: 42
> @@ -425,11 +425,11 @@
> ---------------
>
> ISupportsCommen
> -given set of comments from the remote bugtracker. It takes a bug watch
> -and a list of the comment IDs to retrieve for that bug watch.
> +given set of comments from the remote bugtracker. It takes a remote
> +bug and a list of the comment IDs to retrieve for that bug watch.
It seems everywhere else you've referred to it as a remote bug ID, which
I think is clearer (I was at first expecting it to be an object).
Preview Diff
1 | === modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt' | |||
2 | --- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-12-23 10:49:55 +0000 | |||
3 | +++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2010-01-07 12:59:20 +0000 | |||
4 | @@ -406,7 +406,7 @@ | |||
5 | 406 | a given remote bug. | 406 | a given remote bug. |
6 | 407 | 407 | ||
7 | 408 | >>> bugzilla.xmlrpc_transport.print_method_calls = True | 408 | >>> bugzilla.xmlrpc_transport.print_method_calls = True |
9 | 409 | >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch) | 409 | >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch.remotebug) |
10 | 410 | CALLED Bug.comments({'ids': [1], 'include_fields': ['id']}) | 410 | CALLED Bug.comments({'ids': [1], 'include_fields': ['id']}) |
11 | 411 | 411 | ||
12 | 412 | >>> print sorted(bug_comment_ids) | 412 | >>> print sorted(bug_comment_ids) |
13 | @@ -415,7 +415,7 @@ | |||
14 | 415 | getCommentIds() can only be called if initializeRemoteBugDB() has been | 415 | getCommentIds() can only be called if initializeRemoteBugDB() has been |
15 | 416 | called and the bug exists locally. | 416 | called and the bug exists locally. |
16 | 417 | 417 | ||
18 | 418 | >>> bugzilla.getCommentIds(bug_watch_broken) | 418 | >>> bugzilla.getCommentIds(bug_watch_broken.remotebug) |
19 | 419 | Traceback (most recent call last): | 419 | Traceback (most recent call last): |
20 | 420 | ... | 420 | ... |
21 | 421 | BugNotFound: 42 | 421 | BugNotFound: 42 |
22 | @@ -425,11 +425,11 @@ | |||
23 | 425 | --------------- | 425 | --------------- |
24 | 426 | 426 | ||
25 | 427 | ISupportsCommentImport.fetchComments() is the method used to fetch a | 427 | ISupportsCommentImport.fetchComments() is the method used to fetch a |
28 | 428 | given set of comments from the remote bugtracker. It takes a bug watch | 428 | given set of comments from the remote bugtracker. It takes a remote |
29 | 429 | and a list of the comment IDs to retrieve for that bug watch. | 429 | bug ID and a list of the comment IDs to retrieve for that bug watch. |
30 | 430 | 430 | ||
31 | 431 | >>> bugzilla.xmlrpc_transport.print_method_calls = False | 431 | >>> bugzilla.xmlrpc_transport.print_method_calls = False |
33 | 432 | >>> bugzilla.fetchComments(bug_watch, ['1', '3']) | 432 | >>> bugzilla.fetchComments(bug_watch.remotebug, ['1', '3']) |
34 | 433 | 433 | ||
35 | 434 | The comments will be stored in the bugs dict as a dict of comment id => | 434 | The comments will be stored in the bugs dict as a dict of comment id => |
36 | 435 | comment dict mappings under the key 'comments'. | 435 | comment dict mappings under the key 'comments'. |
37 | @@ -459,7 +459,7 @@ | |||
38 | 459 | fetchComments() will silently ignore them. | 459 | fetchComments() will silently ignore them. |
39 | 460 | 460 | ||
40 | 461 | >>> bugzilla.xmlrpc_transport.print_method_calls = False | 461 | >>> bugzilla.xmlrpc_transport.print_method_calls = False |
42 | 462 | >>> bugzilla.fetchComments(bug_watch, ['1', '4']) | 462 | >>> bugzilla.fetchComments(bug_watch.remotebug, ['1', '4']) |
43 | 463 | 463 | ||
44 | 464 | >>> comments = bugzilla._bugs[1]['comments'] | 464 | >>> comments = bugzilla._bugs[1]['comments'] |
45 | 465 | >>> for comment_id in sorted(comments): | 465 | >>> for comment_id in sorted(comments): |
46 | @@ -482,8 +482,9 @@ | |||
47 | 482 | ISupportsCommentImport.getPosterForComment() returns a tuple of | 482 | ISupportsCommentImport.getPosterForComment() returns a tuple of |
48 | 483 | (displayname, email) for the author of a remote comment. | 483 | (displayname, email) for the author of a remote comment. |
49 | 484 | 484 | ||
52 | 485 | >>> bugzilla.fetchComments(bug_watch_two, ['2', '4']) | 485 | >>> bugzilla.fetchComments(bug_watch_two.remotebug, ['2', '4']) |
53 | 486 | >>> displayname, email = bugzilla.getPosterForComment(bug_watch_two, '4') | 486 | >>> displayname, email = bugzilla.getPosterForComment( |
54 | 487 | ... bug_watch_two.remotebug, '4') | ||
55 | 487 | >>> print displayname, email | 488 | >>> print displayname, email |
56 | 488 | Ford Prefect ford.prefect@h2g2.com | 489 | Ford Prefect ford.prefect@h2g2.com |
57 | 489 | 490 | ||
58 | @@ -491,7 +492,8 @@ | |||
59 | 491 | address then the method will return displayname = None and will return | 492 | address then the method will return displayname = None and will return |
60 | 492 | the whole of the author's name in the email field. | 493 | the whole of the author's name in the email field. |
61 | 493 | 494 | ||
63 | 494 | >>> displayname, email = bugzilla.getPosterForComment(bug_watch_two, '2') | 495 | >>> displayname, email = bugzilla.getPosterForComment( |
64 | 496 | ... bug_watch_two.remotebug, '2') | ||
65 | 495 | >>> print displayname, email | 497 | >>> print displayname, email |
66 | 496 | None trillian | 498 | None trillian |
67 | 497 | 499 | ||
68 | @@ -500,13 +502,13 @@ | |||
69 | 500 | ---------------------- | 502 | ---------------------- |
70 | 501 | 503 | ||
71 | 502 | ISupportsCommentImport.getMessageForComment() returns a Launchpad | 504 | ISupportsCommentImport.getMessageForComment() returns a Launchpad |
74 | 503 | IMessage instance for a given comment. It takes a bug watch, a comment | 505 | IMessage instance for a given comment. It takes a remote bug ID, a |
75 | 504 | ID and a Person object generated from the return value of | 506 | comment ID and a Person object generated from the return value of |
76 | 505 | getPosterForComment(), above. For the sake of this test we'll use | 507 | getPosterForComment(), above. For the sake of this test we'll use |
77 | 506 | Sample Person as our poster. | 508 | Sample Person as our poster. |
78 | 507 | 509 | ||
79 | 508 | >>> message = bugzilla.getMessageForComment( | 510 | >>> message = bugzilla.getMessageForComment( |
81 | 509 | ... bug_watch_two, '2', sample_person) | 511 | ... bug_watch_two.remotebug, '2', sample_person) |
82 | 510 | >>> print message.text_contents | 512 | >>> print message.text_contents |
83 | 511 | Bring the passengers to the bridge please Marvin. | 513 | Bring the passengers to the bridge please Marvin. |
84 | 512 | 514 | ||
85 | @@ -560,12 +562,12 @@ | |||
86 | 560 | The comment will be stored on the remote server with the other comments. | 562 | The comment will be stored on the remote server with the other comments. |
87 | 561 | 563 | ||
88 | 562 | >>> bugzilla.xmlrpc_transport.print_method_calls = False | 564 | >>> bugzilla.xmlrpc_transport.print_method_calls = False |
90 | 563 | >>> print sorted(bugzilla.getCommentIds(bug_watch)) | 565 | >>> print sorted(bugzilla.getCommentIds(bug_watch.remotebug)) |
91 | 564 | ['1', '3', '5'] | 566 | ['1', '3', '5'] |
92 | 565 | 567 | ||
94 | 566 | >>> bugzilla.fetchComments(bug_watch, ['5']) | 568 | >>> bugzilla.fetchComments(bug_watch.remotebug, ['5']) |
95 | 567 | >>> message = bugzilla.getMessageForComment( | 569 | >>> message = bugzilla.getMessageForComment( |
97 | 568 | ... bug_watch, '5', sample_person) | 570 | ... bug_watch.remotebug, '5', sample_person) |
98 | 569 | >>> print message.text_contents | 571 | >>> print message.text_contents |
99 | 570 | This is a new remote comment. | 572 | This is a new remote comment. |
100 | 571 | <BLANKLINE> | 573 | <BLANKLINE> |
101 | 572 | 574 | ||
102 | === modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt' | |||
103 | --- lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2009-12-23 10:49:55 +0000 | |||
104 | +++ lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2010-01-07 12:59:20 +0000 | |||
105 | @@ -377,7 +377,7 @@ | |||
106 | 377 | comment IDs for a given bug on a remote bugtracker. | 377 | comment IDs for a given bug on a remote bugtracker. |
107 | 378 | 378 | ||
108 | 379 | >>> bugzilla.xmlrpc_transport.print_method_calls = True | 379 | >>> bugzilla.xmlrpc_transport.print_method_calls = True |
110 | 380 | >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch) | 380 | >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch.remotebug) |
111 | 381 | CALLED Launchpad.comments({'bug_ids': [1], 'include_fields': ['id']}) | 381 | CALLED Launchpad.comments({'bug_ids': [1], 'include_fields': ['id']}) |
112 | 382 | 382 | ||
113 | 383 | >>> print sorted(bug_comment_ids) | 383 | >>> print sorted(bug_comment_ids) |
114 | @@ -386,7 +386,7 @@ | |||
115 | 386 | getCommentIds() can only be called if initializeRemoteBugDB() has been | 386 | getCommentIds() can only be called if initializeRemoteBugDB() has been |
116 | 387 | called and the bug exists locally. | 387 | called and the bug exists locally. |
117 | 388 | 388 | ||
119 | 389 | >>> bugzilla.getCommentIds(bug_watch_broken) | 389 | >>> bugzilla.getCommentIds(bug_watch_broken.remotebug) |
120 | 390 | Traceback (most recent call last): | 390 | Traceback (most recent call last): |
121 | 391 | ... | 391 | ... |
122 | 392 | BugNotFound: 42 | 392 | BugNotFound: 42 |
123 | @@ -396,11 +396,11 @@ | |||
124 | 396 | --------------- | 396 | --------------- |
125 | 397 | 397 | ||
126 | 398 | ISupportsCommentImport.fetchComments() is the method used to fetch a | 398 | ISupportsCommentImport.fetchComments() is the method used to fetch a |
129 | 399 | given set of comments from the remote bugtracker. It takes a bug watch | 399 | given set of comments from the remote bugtracker. It takes a remote |
130 | 400 | and a list of the comment IDs to retrieve for that bug watch. | 400 | bug ID and a list of the comment IDs to retrieve for that bug watch. |
131 | 401 | 401 | ||
132 | 402 | >>> bugzilla.xmlrpc_transport.print_method_calls = False | 402 | >>> bugzilla.xmlrpc_transport.print_method_calls = False |
134 | 403 | >>> bugzilla.fetchComments(bug_watch, ['1', '3']) | 403 | >>> bugzilla.fetchComments(bug_watch.remotebug, ['1', '3']) |
135 | 404 | 404 | ||
136 | 405 | The comments will be stored in the bugs dict as a dict of comment id => | 405 | The comments will be stored in the bugs dict as a dict of comment id => |
137 | 406 | comment dict mappings under the key 'comments'. | 406 | comment dict mappings under the key 'comments'. |
138 | @@ -466,11 +466,12 @@ | |||
139 | 466 | The comment will be stored on the remote server with the other comments. | 466 | The comment will be stored on the remote server with the other comments. |
140 | 467 | 467 | ||
141 | 468 | >>> bugzilla.xmlrpc_transport.print_method_calls = False | 468 | >>> bugzilla.xmlrpc_transport.print_method_calls = False |
143 | 469 | >>> print sorted(bugzilla.getCommentIds(bug_watch)) | 469 | >>> print sorted(bugzilla.getCommentIds(bug_watch.remotebug)) |
144 | 470 | ['1', '3', '5'] | 470 | ['1', '3', '5'] |
145 | 471 | 471 | ||
148 | 472 | >>> bugzilla.fetchComments(bug_watch, ['5']) | 472 | >>> bugzilla.fetchComments(bug_watch.remotebug, ['5']) |
149 | 473 | >>> message = bugzilla.getMessageForComment(bug_watch, '5', sample_person) | 473 | >>> message = bugzilla.getMessageForComment( |
150 | 474 | ... bug_watch.remotebug, '5', sample_person) | ||
151 | 474 | >>> print message.text_contents | 475 | >>> print message.text_contents |
152 | 475 | This is a new remote comment. | 476 | This is a new remote comment. |
153 | 476 | <BLANKLINE> | 477 | <BLANKLINE> |
154 | 477 | 478 | ||
155 | === modified file 'lib/lp/bugs/doc/externalbugtracker-debbugs.txt' | |||
156 | --- lib/lp/bugs/doc/externalbugtracker-debbugs.txt 2009-10-08 03:44:20 +0000 | |||
157 | +++ lib/lp/bugs/doc/externalbugtracker-debbugs.txt 2010-01-07 12:59:20 +0000 | |||
158 | @@ -361,7 +361,7 @@ | |||
159 | 361 | getCommentIds() will return a list of the comment IDs for a given remote | 361 | getCommentIds() will return a list of the comment IDs for a given remote |
160 | 362 | bug. DebBugs comment IDs are RFC822 message IDs. | 362 | bug. DebBugs comment IDs are RFC822 message IDs. |
161 | 363 | 363 | ||
163 | 364 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch) | 364 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug) |
164 | 365 | >>> print comment_ids | 365 | >>> print comment_ids |
165 | 366 | ['<20040309081430.98BF411EE67@tux>'] | 366 | ['<20040309081430.98BF411EE67@tux>'] |
166 | 367 | 367 | ||
167 | @@ -371,7 +371,7 @@ | |||
168 | 371 | >>> external_debbugs.debbugs_db._data_file = ( | 371 | >>> external_debbugs.debbugs_db._data_file = ( |
169 | 372 | ... 'debbugs-comment-with-no-date.txt') | 372 | ... 'debbugs-comment-with-no-date.txt') |
170 | 373 | 373 | ||
172 | 374 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch) | 374 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug) |
173 | 375 | >>> print comment_ids | 375 | >>> print comment_ids |
174 | 376 | [] | 376 | [] |
175 | 377 | 377 | ||
176 | @@ -396,7 +396,7 @@ | |||
177 | 396 | 396 | ||
178 | 397 | However, getCommentIds() will only return the comment ID once. | 397 | However, getCommentIds() will only return the comment ID once. |
179 | 398 | 398 | ||
181 | 399 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch) | 399 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug) |
182 | 400 | >>> print comment_ids | 400 | >>> print comment_ids |
183 | 401 | ['<20040309081430.98BF411EE67@tux>'] | 401 | ['<20040309081430.98BF411EE67@tux>'] |
184 | 402 | 402 | ||
185 | @@ -412,7 +412,7 @@ | |||
186 | 412 | 412 | ||
187 | 413 | >>> comment_id = comment_ids[0] | 413 | >>> comment_id = comment_ids[0] |
188 | 414 | >>> poster_name, poster_email = external_debbugs.getPosterForComment( | 414 | >>> poster_name, poster_email = external_debbugs.getPosterForComment( |
190 | 415 | ... bug_watch, comment_id) | 415 | ... bug_watch.remotebug, comment_id) |
191 | 416 | >>> print "%s <%s>" % (poster_name, poster_email) | 416 | >>> print "%s <%s>" % (poster_name, poster_email) |
192 | 417 | Teun Vink <teun@tux.office.luna.net> | 417 | Teun Vink <teun@tux.office.luna.net> |
193 | 418 | 418 | ||
194 | @@ -427,7 +427,7 @@ | |||
195 | 427 | ... comment='when importing comments for %s.' % bug_watch.title) | 427 | ... comment='when importing comments for %s.' % bug_watch.title) |
196 | 428 | 428 | ||
197 | 429 | >>> message = external_debbugs.getMessageForComment( | 429 | >>> message = external_debbugs.getMessageForComment( |
199 | 430 | ... bug_watch, comment_id, poster) | 430 | ... bug_watch.remotebug, comment_id, poster) |
200 | 431 | 431 | ||
201 | 432 | >>> print message.owner.displayname | 432 | >>> print message.owner.displayname |
202 | 433 | Teun Vink | 433 | Teun Vink |
203 | @@ -445,13 +445,13 @@ | |||
204 | 445 | >>> external_debbugs.debbugs_db._data_file = ( | 445 | >>> external_debbugs.debbugs_db._data_file = ( |
205 | 446 | ... 'debbugs-comment-with-received-date.txt') | 446 | ... 'debbugs-comment-with-received-date.txt') |
206 | 447 | 447 | ||
208 | 448 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch) | 448 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug) |
209 | 449 | >>> print comment_ids | 449 | >>> print comment_ids |
210 | 450 | ['<yetanothermessageid@launchpad>'] | 450 | ['<yetanothermessageid@launchpad>'] |
211 | 451 | 451 | ||
212 | 452 | >>> external_debbugs.fetchComments(bug_watch, comment_ids) | 452 | >>> external_debbugs.fetchComments(bug_watch, comment_ids) |
213 | 453 | >>> message = external_debbugs.getMessageForComment( | 453 | >>> message = external_debbugs.getMessageForComment( |
215 | 454 | ... bug_watch, comment_ids[0], poster) | 454 | ... bug_watch.remotebug, comment_ids[0], poster) |
216 | 455 | 455 | ||
217 | 456 | >>> print message.datecreated | 456 | >>> print message.datecreated |
218 | 457 | 2008-05-30 21:18:12+00:00 | 457 | 2008-05-30 21:18:12+00:00 |
219 | @@ -477,11 +477,11 @@ | |||
220 | 477 | >>> external_debbugs.debbugs_db._data_file = ( | 477 | >>> external_debbugs.debbugs_db._data_file = ( |
221 | 478 | ... 'debbugs-comment-with-no-useful-received-date.txt') | 478 | ... 'debbugs-comment-with-no-useful-received-date.txt') |
222 | 479 | 479 | ||
224 | 480 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch) | 480 | >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug) |
225 | 481 | 481 | ||
226 | 482 | >>> external_debbugs.fetchComments(bug_watch, comment_ids) | 482 | >>> external_debbugs.fetchComments(bug_watch, comment_ids) |
227 | 483 | >>> message = external_debbugs.getMessageForComment( | 483 | >>> message = external_debbugs.getMessageForComment( |
229 | 484 | ... bug_watch, comment_ids[0], poster) | 484 | ... bug_watch.remotebug, comment_ids[0], poster) |
230 | 485 | 485 | ||
231 | 486 | >>> print message.datecreated | 486 | >>> print message.datecreated |
232 | 487 | 2007-12-14 18:54:30+00:00 | 487 | 2007-12-14 18:54:30+00:00 |
233 | 488 | 488 | ||
234 | === modified file 'lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt' | |||
235 | --- lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt 2009-06-12 16:36:02 +0000 | |||
236 | +++ lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt 2010-01-07 12:59:20 +0000 | |||
237 | @@ -362,7 +362,7 @@ | |||
238 | 362 | >>> commit() | 362 | >>> commit() |
239 | 363 | >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser) | 363 | >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser) |
240 | 364 | 364 | ||
242 | 365 | getCommentIds() returns all the comment IDs for a given bug watch. | 365 | getCommentIds() returns all the comment IDs for a given remote bug. |
243 | 366 | bug_watch is against remote bug 1, which has one comment. | 366 | bug_watch is against remote bug 1, which has one comment. |
244 | 367 | 367 | ||
245 | 368 | >>> test_transport.expireCookie(test_transport.auth_cookie) | 368 | >>> test_transport.expireCookie(test_transport.auth_cookie) |
246 | @@ -371,23 +371,23 @@ | |||
247 | 371 | Using XML-RPC to generate token. | 371 | Using XML-RPC to generate token. |
248 | 372 | Successfully validated the token. | 372 | Successfully validated the token. |
249 | 373 | 373 | ||
251 | 374 | >>> trac.getCommentIds(bug_watch) | 374 | >>> trac.getCommentIds(bug_watch.remotebug) |
252 | 375 | ['1-1'] | 375 | ['1-1'] |
253 | 376 | 376 | ||
254 | 377 | bug_watch_two is against remote bug 2, which has two comments. | 377 | bug_watch_two is against remote bug 2, which has two comments. |
255 | 378 | 378 | ||
257 | 379 | >>> trac.getCommentIds(bug_watch_two) | 379 | >>> trac.getCommentIds(bug_watch_two.remotebug) |
258 | 380 | ['2-1', '2-2'] | 380 | ['2-1', '2-2'] |
259 | 381 | 381 | ||
260 | 382 | bug_watch_three is against bug 3, which has no comments. | 382 | bug_watch_three is against bug 3, which has no comments. |
261 | 383 | 383 | ||
263 | 384 | >>> trac.getCommentIds(bug_watch_three) | 384 | >>> trac.getCommentIds(bug_watch_three.remotebug) |
264 | 385 | [] | 385 | [] |
265 | 386 | 386 | ||
266 | 387 | Trying to call getCommentIds() on a bug that doesn't exist will raise a | 387 | Trying to call getCommentIds() on a bug that doesn't exist will raise a |
267 | 388 | BugNotFound error. | 388 | BugNotFound error. |
268 | 389 | 389 | ||
270 | 390 | >>> trac.getCommentIds(bug_watch_broken) | 390 | >>> trac.getCommentIds(bug_watch_broken.remotebug) |
271 | 391 | Traceback (most recent call last): | 391 | Traceback (most recent call last): |
272 | 392 | ... | 392 | ... |
273 | 393 | BugNotFound: 123 | 393 | BugNotFound: 123 |
274 | @@ -406,7 +406,7 @@ | |||
275 | 406 | parsed. | 406 | parsed. |
276 | 407 | 407 | ||
277 | 408 | >>> test_transport.expireCookie(test_transport.auth_cookie) | 408 | >>> test_transport.expireCookie(test_transport.auth_cookie) |
279 | 409 | >>> trac.fetchComments(bug_watch, ['1-1']) | 409 | >>> trac.fetchComments(bug_watch.remotebug, ['1-1']) |
280 | 410 | Using XML-RPC to generate token. | 410 | Using XML-RPC to generate token. |
281 | 411 | Successfully validated the token. | 411 | Successfully validated the token. |
282 | 412 | 412 | ||
283 | @@ -422,7 +422,7 @@ | |||
284 | 422 | getPosterForComment() returns a tuple of (displayname, emailaddress) for | 422 | getPosterForComment() returns a tuple of (displayname, emailaddress) for |
285 | 423 | the poster of a given comment. | 423 | the poster of a given comment. |
286 | 424 | 424 | ||
288 | 425 | >>> trac.getPosterForComment(bug_watch, '1-1') | 425 | >>> trac.getPosterForComment(bug_watch.remotebug, '1-1') |
289 | 426 | ('Test', 'test@canonical.com') | 426 | ('Test', 'test@canonical.com') |
290 | 427 | 427 | ||
291 | 428 | getPosterForComment() handles situations in which only an email address | 428 | getPosterForComment() handles situations in which only an email address |
292 | @@ -430,8 +430,8 @@ | |||
293 | 430 | displayname. When this is passed to IPersonSet.ensurePerson() a display | 430 | displayname. When this is passed to IPersonSet.ensurePerson() a display |
294 | 431 | name will be generated for the user from their email address. | 431 | name will be generated for the user from their email address. |
295 | 432 | 432 | ||
298 | 433 | >>> trac.fetchComments(bug_watch_two, ['2-1', '2-2']) | 433 | >>> trac.fetchComments(bug_watch_two.remotebug, ['2-1', '2-2']) |
299 | 434 | >>> trac.getPosterForComment(bug_watch_two, '2-1') | 434 | >>> trac.getPosterForComment(bug_watch_two.remotebug, '2-1') |
300 | 435 | (None, 'test@canonical.com') | 435 | (None, 'test@canonical.com') |
301 | 436 | 436 | ||
302 | 437 | getPosterForComment() will also return displayname, email tuples in | 437 | getPosterForComment() will also return displayname, email tuples in |
303 | @@ -439,7 +439,7 @@ | |||
304 | 439 | However, in these cases it is the email address that will be set to | 439 | However, in these cases it is the email address that will be set to |
305 | 440 | None. | 440 | None. |
306 | 441 | 441 | ||
308 | 442 | >>> trac.getPosterForComment(bug_watch_two, '2-2') | 442 | >>> trac.getPosterForComment(bug_watch_two.remotebug, '2-2') |
309 | 443 | ('foo.bar', None) | 443 | ('foo.bar', None) |
310 | 444 | 444 | ||
311 | 445 | Finally, getMessageForComment() will return a Message instance for a | 445 | Finally, getMessageForComment() will return a Message instance for a |
312 | @@ -448,7 +448,8 @@ | |||
313 | 448 | 448 | ||
314 | 449 | >>> from zope.component import getUtility | 449 | >>> from zope.component import getUtility |
315 | 450 | >>> poster = getUtility(IPersonSet).getByEmail('test@canonical.com') | 450 | >>> poster = getUtility(IPersonSet).getByEmail('test@canonical.com') |
317 | 451 | >>> message_one = trac.getMessageForComment(bug_watch, '1-1', poster) | 451 | >>> message_one = trac.getMessageForComment( |
318 | 452 | ... bug_watch.remotebug, '1-1', poster) | ||
319 | 452 | 453 | ||
320 | 453 | The Message returned by getMessageForComment() contains the full text of | 454 | The Message returned by getMessageForComment() contains the full text of |
321 | 454 | the original comment. | 455 | the original comment. |
322 | 455 | 456 | ||
323 | === modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py' | |||
324 | --- lib/lp/bugs/externalbugtracker/bugzilla.py 2009-12-23 10:49:55 +0000 | |||
325 | +++ lib/lp/bugs/externalbugtracker/bugzilla.py 2010-01-07 12:59:20 +0000 | |||
326 | @@ -626,13 +626,13 @@ | |||
327 | 626 | 626 | ||
328 | 627 | return bug_products | 627 | return bug_products |
329 | 628 | 628 | ||
331 | 629 | def getCommentIds(self, bug_watch): | 629 | def getCommentIds(self, remote_bug_id): |
332 | 630 | """See `ISupportsCommentImport`.""" | 630 | """See `ISupportsCommentImport`.""" |
334 | 631 | actual_bug_id = self._getActualBugId(bug_watch.remotebug) | 631 | actual_bug_id = self._getActualBugId(remote_bug_id) |
335 | 632 | 632 | ||
336 | 633 | # Check that the bug exists, first. | 633 | # Check that the bug exists, first. |
337 | 634 | if actual_bug_id not in self._bugs: | 634 | if actual_bug_id not in self._bugs: |
339 | 635 | raise BugNotFound(bug_watch.remotebug) | 635 | raise BugNotFound(remote_bug_id) |
340 | 636 | 636 | ||
341 | 637 | # Get only the remote comment IDs and store them in the | 637 | # Get only the remote comment IDs and store them in the |
342 | 638 | # 'comments' field of the bug. | 638 | # 'comments' field of the bug. |
343 | @@ -648,9 +648,9 @@ | |||
344 | 648 | 648 | ||
345 | 649 | return [str(comment['id']) for comment in bug_comments] | 649 | return [str(comment['id']) for comment in bug_comments] |
346 | 650 | 650 | ||
348 | 651 | def fetchComments(self, bug_watch, comment_ids): | 651 | def fetchComments(self, remote_bug_id, comment_ids): |
349 | 652 | """See `ISupportsCommentImport`.""" | 652 | """See `ISupportsCommentImport`.""" |
351 | 653 | actual_bug_id = self._getActualBugId(bug_watch.remotebug) | 653 | actual_bug_id = self._getActualBugId(remote_bug_id) |
352 | 654 | 654 | ||
353 | 655 | # We need to cast comment_ids to integers, since | 655 | # We need to cast comment_ids to integers, since |
354 | 656 | # BugWatchUpdater.importBugComments() will pass us a list of | 656 | # BugWatchUpdater.importBugComments() will pass us a list of |
355 | @@ -664,7 +664,7 @@ | |||
356 | 664 | comments = return_dict['comments'] | 664 | comments = return_dict['comments'] |
357 | 665 | 665 | ||
358 | 666 | # As a sanity check, drop any comments that don't belong to the | 666 | # As a sanity check, drop any comments that don't belong to the |
360 | 667 | # bug in bug_watch. | 667 | # bug in remote_bug_id. |
361 | 668 | for comment_id, comment in comments.items(): | 668 | for comment_id, comment in comments.items(): |
362 | 669 | if int(comment['bug_id']) != actual_bug_id: | 669 | if int(comment['bug_id']) != actual_bug_id: |
363 | 670 | del comments[comment_id] | 670 | del comments[comment_id] |
364 | @@ -674,9 +674,9 @@ | |||
365 | 674 | (int(id), comments[id]) for id in comments) | 674 | (int(id), comments[id]) for id in comments) |
366 | 675 | self._bugs[actual_bug_id]['comments'] = comments_with_int_ids | 675 | self._bugs[actual_bug_id]['comments'] = comments_with_int_ids |
367 | 676 | 676 | ||
369 | 677 | def getPosterForComment(self, bug_watch, comment_id): | 677 | def getPosterForComment(self, remote_bug_id, comment_id): |
370 | 678 | """See `ISupportsCommentImport`.""" | 678 | """See `ISupportsCommentImport`.""" |
372 | 679 | actual_bug_id = self._getActualBugId(bug_watch.remotebug) | 679 | actual_bug_id = self._getActualBugId(remote_bug_id) |
373 | 680 | 680 | ||
374 | 681 | # We need to cast comment_id to integers, since | 681 | # We need to cast comment_id to integers, since |
375 | 682 | # BugWatchUpdater.importBugComments() will pass us a string (see | 682 | # BugWatchUpdater.importBugComments() will pass us a string (see |
376 | @@ -693,9 +693,9 @@ | |||
377 | 693 | 693 | ||
378 | 694 | return (display_name, email) | 694 | return (display_name, email) |
379 | 695 | 695 | ||
381 | 696 | def getMessageForComment(self, bug_watch, comment_id, poster): | 696 | def getMessageForComment(self, remote_bug_id, comment_id, poster): |
382 | 697 | """See `ISupportsCommentImport`.""" | 697 | """See `ISupportsCommentImport`.""" |
384 | 698 | actual_bug_id = self._getActualBugId(bug_watch.remotebug) | 698 | actual_bug_id = self._getActualBugId(remote_bug_id) |
385 | 699 | 699 | ||
386 | 700 | # We need to cast comment_id to integers, since | 700 | # We need to cast comment_id to integers, since |
387 | 701 | # BugWatchUpdater.importBugComments() will pass us a string (see | 701 | # BugWatchUpdater.importBugComments() will pass us a string (see |
388 | @@ -845,13 +845,13 @@ | |||
389 | 845 | server_utc_time = time_dict['utc_time'] | 845 | server_utc_time = time_dict['utc_time'] |
390 | 846 | return server_utc_time.replace(tzinfo=pytz.timezone('UTC')) | 846 | return server_utc_time.replace(tzinfo=pytz.timezone('UTC')) |
391 | 847 | 847 | ||
393 | 848 | def getCommentIds(self, bug_watch): | 848 | def getCommentIds(self, remote_bug_id): |
394 | 849 | """See `ISupportsCommentImport`.""" | 849 | """See `ISupportsCommentImport`.""" |
396 | 850 | actual_bug_id = self._getActualBugId(bug_watch.remotebug) | 850 | actual_bug_id = self._getActualBugId(remote_bug_id) |
397 | 851 | 851 | ||
398 | 852 | # Check that the bug exists, first. | 852 | # Check that the bug exists, first. |
399 | 853 | if actual_bug_id not in self._bugs: | 853 | if actual_bug_id not in self._bugs: |
401 | 854 | raise BugNotFound(bug_watch.remotebug) | 854 | raise BugNotFound(remote_bug_id) |
402 | 855 | 855 | ||
403 | 856 | # Get only the remote comment IDs and store them in the | 856 | # Get only the remote comment IDs and store them in the |
404 | 857 | # 'comments' field of the bug. | 857 | # 'comments' field of the bug. |
405 | @@ -871,9 +871,9 @@ | |||
406 | 871 | # bug 248938). | 871 | # bug 248938). |
407 | 872 | return [str(comment['id']) for comment in bug_comments] | 872 | return [str(comment['id']) for comment in bug_comments] |
408 | 873 | 873 | ||
410 | 874 | def fetchComments(self, bug_watch, comment_ids): | 874 | def fetchComments(self, remote_bug_id, comment_ids): |
411 | 875 | """See `ISupportsCommentImport`.""" | 875 | """See `ISupportsCommentImport`.""" |
413 | 876 | actual_bug_id = self._getActualBugId(bug_watch.remotebug) | 876 | actual_bug_id = self._getActualBugId(remote_bug_id) |
414 | 877 | 877 | ||
415 | 878 | # We need to cast comment_ids to integers, since | 878 | # We need to cast comment_ids to integers, since |
416 | 879 | # BugWatchUpdater.importBugComments() will pass us a list of | 879 | # BugWatchUpdater.importBugComments() will pass us a list of |
417 | 880 | 880 | ||
418 | === modified file 'lib/lp/bugs/externalbugtracker/debbugs.py' | |||
419 | --- lib/lp/bugs/externalbugtracker/debbugs.py 2009-10-06 07:38:29 +0000 | |||
420 | +++ lib/lp/bugs/externalbugtracker/debbugs.py 2010-01-07 12:59:20 +0000 | |||
421 | @@ -221,9 +221,9 @@ | |||
422 | 221 | debian_bug = self._findBug(remote_bug) | 221 | debian_bug = self._findBug(remote_bug) |
423 | 222 | return debian_bug.subject, debian_bug.description | 222 | return debian_bug.subject, debian_bug.description |
424 | 223 | 223 | ||
426 | 224 | def getCommentIds(self, bug_watch): | 224 | def getCommentIds(self, remote_bug_id): |
427 | 225 | """See `ISupportsCommentImport`.""" | 225 | """See `ISupportsCommentImport`.""" |
429 | 226 | debian_bug = self._findBug(bug_watch.remotebug) | 226 | debian_bug = self._findBug(remote_bug_id) |
430 | 227 | self._loadLog(debian_bug) | 227 | self._loadLog(debian_bug) |
431 | 228 | 228 | ||
432 | 229 | comment_ids = [] | 229 | comment_ids = [] |
433 | @@ -244,16 +244,16 @@ | |||
434 | 244 | 244 | ||
435 | 245 | return comment_ids | 245 | return comment_ids |
436 | 246 | 246 | ||
438 | 247 | def fetchComments(self, bug_watch, comment_ids): | 247 | def fetchComments(self, remote_bug_id, comment_ids): |
439 | 248 | """See `ISupportsCommentImport`.""" | 248 | """See `ISupportsCommentImport`.""" |
440 | 249 | # This method does nothing since DebBugs bugs are stored locally | 249 | # This method does nothing since DebBugs bugs are stored locally |
441 | 250 | # and their comments don't need to be pre-fetched. It exists | 250 | # and their comments don't need to be pre-fetched. It exists |
442 | 251 | # purely to ensure that BugWatchUpdater doesn't choke on it. | 251 | # purely to ensure that BugWatchUpdater doesn't choke on it. |
443 | 252 | pass | 252 | pass |
444 | 253 | 253 | ||
446 | 254 | def getPosterForComment(self, bug_watch, comment_id): | 254 | def getPosterForComment(self, remote_bug_id, comment_id): |
447 | 255 | """See `ISupportsCommentImport`.""" | 255 | """See `ISupportsCommentImport`.""" |
449 | 256 | debian_bug = self._findBug(bug_watch.remotebug) | 256 | debian_bug = self._findBug(remote_bug_id) |
450 | 257 | self._loadLog(debian_bug) | 257 | self._loadLog(debian_bug) |
451 | 258 | 258 | ||
452 | 259 | for comment in debian_bug.comments: | 259 | for comment in debian_bug.comments: |
453 | @@ -304,9 +304,9 @@ | |||
454 | 304 | 304 | ||
455 | 305 | return msg_date | 305 | return msg_date |
456 | 306 | 306 | ||
458 | 307 | def getMessageForComment(self, bug_watch, comment_id, poster): | 307 | def getMessageForComment(self, remote_bug_id, comment_id, poster): |
459 | 308 | """See `ISupportsCommentImport`.""" | 308 | """See `ISupportsCommentImport`.""" |
461 | 309 | debian_bug = self._findBug(bug_watch.remotebug) | 309 | debian_bug = self._findBug(remote_bug_id) |
462 | 310 | self._loadLog(debian_bug) | 310 | self._loadLog(debian_bug) |
463 | 311 | 311 | ||
464 | 312 | for comment in debian_bug.comments: | 312 | for comment in debian_bug.comments: |
465 | 313 | 313 | ||
466 | === modified file 'lib/lp/bugs/externalbugtracker/trac.py' | |||
467 | --- lib/lp/bugs/externalbugtracker/trac.py 2009-06-25 00:40:31 +0000 | |||
468 | +++ lib/lp/bugs/externalbugtracker/trac.py 2010-01-07 12:59:20 +0000 | |||
469 | @@ -378,17 +378,17 @@ | |||
470 | 378 | 378 | ||
471 | 379 | return [bug['id'] for bug in modified_bugs] | 379 | return [bug['id'] for bug in modified_bugs] |
472 | 380 | 380 | ||
474 | 381 | def getCommentIds(self, bug_watch): | 381 | def getCommentIds(self, remote_bug_id): |
475 | 382 | """See `ISupportsCommentImport`.""" | 382 | """See `ISupportsCommentImport`.""" |
476 | 383 | try: | 383 | try: |
478 | 384 | bug = self.bugs[int(bug_watch.remotebug)] | 384 | bug = self.bugs[int(remote_bug_id)] |
479 | 385 | except KeyError: | 385 | except KeyError: |
481 | 386 | raise BugNotFound(bug_watch.remotebug) | 386 | raise BugNotFound(remote_bug_id) |
482 | 387 | else: | 387 | else: |
483 | 388 | return [comment_id for comment_id in bug['comments']] | 388 | return [comment_id for comment_id in bug['comments']] |
484 | 389 | 389 | ||
485 | 390 | @needs_authentication | 390 | @needs_authentication |
487 | 391 | def fetchComments(self, bug_watch, comment_ids): | 391 | def fetchComments(self, remote_bug_id, comment_ids): |
488 | 392 | """See `ISupportsCommentImport`.""" | 392 | """See `ISupportsCommentImport`.""" |
489 | 393 | bug_comments = {} | 393 | bug_comments = {} |
490 | 394 | 394 | ||
491 | @@ -402,11 +402,11 @@ | |||
492 | 402 | # Finally, we overwrite the bug's comments field with the | 402 | # Finally, we overwrite the bug's comments field with the |
493 | 403 | # bug_comments dict. The nice upshot of this is that we can | 403 | # bug_comments dict. The nice upshot of this is that we can |
494 | 404 | # still loop over the dict and get IDs back. | 404 | # still loop over the dict and get IDs back. |
496 | 405 | self.bugs[int(bug_watch.remotebug)]['comments'] = bug_comments | 405 | self.bugs[int(remote_bug_id)]['comments'] = bug_comments |
497 | 406 | 406 | ||
499 | 407 | def getPosterForComment(self, bug_watch, comment_id): | 407 | def getPosterForComment(self, remote_bug_id, comment_id): |
500 | 408 | """See `ISupportsCommentImport`.""" | 408 | """See `ISupportsCommentImport`.""" |
502 | 409 | bug = self.bugs[int(bug_watch.remotebug)] | 409 | bug = self.bugs[int(remote_bug_id)] |
503 | 410 | comment = bug['comments'][comment_id] | 410 | comment = bug['comments'][comment_id] |
504 | 411 | 411 | ||
505 | 412 | display_name, email = parseaddr(comment['user']) | 412 | display_name, email = parseaddr(comment['user']) |
506 | @@ -424,9 +424,9 @@ | |||
507 | 424 | else: | 424 | else: |
508 | 425 | return display_name, email | 425 | return display_name, email |
509 | 426 | 426 | ||
511 | 427 | def getMessageForComment(self, bug_watch, comment_id, poster): | 427 | def getMessageForComment(self, remote_bug_id, comment_id, poster): |
512 | 428 | """See `ISupportsCommentImport`.""" | 428 | """See `ISupportsCommentImport`.""" |
514 | 429 | bug = self.bugs[int(bug_watch.remotebug)] | 429 | bug = self.bugs[int(remote_bug_id)] |
515 | 430 | comment = bug['comments'][comment_id] | 430 | comment = bug['comments'][comment_id] |
516 | 431 | 431 | ||
517 | 432 | comment_datecreated = datetime.fromtimestamp( | 432 | comment_datecreated = datetime.fromtimestamp( |
518 | 433 | 433 | ||
519 | === modified file 'lib/lp/bugs/interfaces/externalbugtracker.py' | |||
520 | --- lib/lp/bugs/interfaces/externalbugtracker.py 2009-12-18 16:37:11 +0000 | |||
521 | +++ lib/lp/bugs/interfaces/externalbugtracker.py 2010-01-07 12:59:20 +0000 | |||
522 | @@ -103,36 +103,41 @@ | |||
523 | 103 | class ISupportsCommentImport(IExternalBugTracker): | 103 | class ISupportsCommentImport(IExternalBugTracker): |
524 | 104 | """An external bug tracker that supports comment imports.""" | 104 | """An external bug tracker that supports comment imports.""" |
525 | 105 | 105 | ||
527 | 106 | def fetchComments(bug_watch, comment_ids): | 106 | def fetchComments(remote_bug_id, comment_ids): |
528 | 107 | """Load a given set of remote comments, ready for parsing. | 107 | """Load a given set of remote comments, ready for parsing. |
529 | 108 | 108 | ||
531 | 109 | :param bug_watch: The bug watch for which to fetch the comments. | 109 | :param remote_bug_id: The ID of the remote bug from which to |
532 | 110 | fetch comments. | ||
533 | 111 | :type remote_bug_id: See `IBugWatch.remotebug`. | ||
534 | 110 | :param comment_ids: A list of the IDs of the comments to load. | 112 | :param comment_ids: A list of the IDs of the comments to load. |
535 | 111 | """ | 113 | """ |
536 | 112 | 114 | ||
538 | 113 | def getCommentIds(bug_watch): | 115 | def getCommentIds(remote_bug_id): |
539 | 114 | """Return all the comment IDs for a given remote bug. | 116 | """Return all the comment IDs for a given remote bug. |
540 | 115 | 117 | ||
543 | 116 | :param bug_watch: An `IBugWatch` pointing to the remote bug from | 118 | :param remote_bug_id: The ID of the remote bug from which |
544 | 117 | which comments should be imported. | 119 | comments should be imported. |
545 | 120 | :type remote_bug_id: See `IBugWatch.remotebug`. | ||
546 | 118 | :return: A list of strings, each of which is the ID of one | 121 | :return: A list of strings, each of which is the ID of one |
547 | 119 | comment on the remote bug. | 122 | comment on the remote bug. |
548 | 120 | """ | 123 | """ |
549 | 121 | 124 | ||
551 | 122 | def getPosterForComment(bug_watch, comment_id): | 125 | def getPosterForComment(remote_bug_id, comment_id): |
552 | 123 | """Return a tuple of (name, emailaddress) for a comment's poster. | 126 | """Return a tuple of (name, emailaddress) for a comment's poster. |
553 | 124 | 127 | ||
556 | 125 | :param bug_watch: An `IBugWatch` pointing to the remote bug from | 128 | :param remote_bug_id: The ID of the remote bug from which |
557 | 126 | which comments should be imported. | 129 | comments have been imported. |
558 | 130 | :type remote_bug_id: See `IBugWatch.remotebug`. | ||
559 | 127 | :param comment_id: A string representing the remote comment ID | 131 | :param comment_id: A string representing the remote comment ID |
560 | 128 | from which the poster's details should be extracted. | 132 | from which the poster's details should be extracted. |
561 | 129 | """ | 133 | """ |
562 | 130 | 134 | ||
564 | 131 | def getMessageForComment(bug_watch, comment_id, poster): | 135 | def getMessageForComment(remote_bug_id, comment_id, poster): |
565 | 132 | """Return an `IMessage` instance for a comment. | 136 | """Return an `IMessage` instance for a comment. |
566 | 133 | 137 | ||
569 | 134 | :param bug_watch: An `IBugWatch` pointing to the remote bug from | 138 | :param remote_bug_id: The ID of the remote bug from which |
570 | 135 | which comments should be imported. | 139 | comments have been imported. |
571 | 140 | :type remote_bug_id: See `IBugWatch.remotebug`. | ||
572 | 136 | :param comment_id: A string representing the remote comment ID | 141 | :param comment_id: A string representing the remote comment ID |
573 | 137 | from which the returned `IMessage` should be created. | 142 | from which the returned `IMessage` should be created. |
574 | 138 | """ | 143 | """ |
575 | 139 | 144 | ||
576 | === modified file 'lib/lp/bugs/scripts/checkwatches.py' | |||
577 | --- lib/lp/bugs/scripts/checkwatches.py 2010-01-05 16:09:00 +0000 | |||
578 | +++ lib/lp/bugs/scripts/checkwatches.py 2010-01-07 12:59:20 +0000 | |||
579 | @@ -951,19 +951,21 @@ | |||
580 | 951 | """ | 951 | """ |
581 | 952 | # Construct a list of the comment IDs we want to import; i.e. | 952 | # Construct a list of the comment IDs we want to import; i.e. |
582 | 953 | # those which we haven't already imported. | 953 | # those which we haven't already imported. |
584 | 954 | all_comment_ids = external_bugtracker.getCommentIds(bug_watch) | 954 | all_comment_ids = external_bugtracker.getCommentIds( |
585 | 955 | bug_watch.remotebug) | ||
586 | 955 | comment_ids_to_import = [ | 956 | comment_ids_to_import = [ |
587 | 956 | comment_id for comment_id in all_comment_ids | 957 | comment_id for comment_id in all_comment_ids |
588 | 957 | if not bug_watch.hasComment(comment_id)] | 958 | if not bug_watch.hasComment(comment_id)] |
589 | 958 | 959 | ||
591 | 959 | external_bugtracker.fetchComments(bug_watch, comment_ids_to_import) | 960 | external_bugtracker.fetchComments( |
592 | 961 | bug_watch.remotebug, comment_ids_to_import) | ||
593 | 960 | 962 | ||
594 | 961 | previous_imported_comments = bug_watch.getImportedBugMessages() | 963 | previous_imported_comments = bug_watch.getImportedBugMessages() |
595 | 962 | is_initial_import = previous_imported_comments.count() == 0 | 964 | is_initial_import = previous_imported_comments.count() == 0 |
596 | 963 | imported_comments = [] | 965 | imported_comments = [] |
597 | 964 | for comment_id in comment_ids_to_import: | 966 | for comment_id in comment_ids_to_import: |
598 | 965 | displayname, email = external_bugtracker.getPosterForComment( | 967 | displayname, email = external_bugtracker.getPosterForComment( |
600 | 966 | bug_watch, comment_id) | 968 | bug_watch.remotebug, comment_id) |
601 | 967 | 969 | ||
602 | 968 | if displayname is None and email is None: | 970 | if displayname is None and email is None: |
603 | 969 | # If we don't have a displayname or an email address | 971 | # If we don't have a displayname or an email address |
604 | @@ -981,7 +983,7 @@ | |||
605 | 981 | "when importing comments for %s." % bug_watch.title) | 983 | "when importing comments for %s." % bug_watch.title) |
606 | 982 | 984 | ||
607 | 983 | comment_message = external_bugtracker.getMessageForComment( | 985 | comment_message = external_bugtracker.getMessageForComment( |
609 | 984 | bug_watch, comment_id, poster) | 986 | bug_watch.remotebug, comment_id, poster) |
610 | 985 | 987 | ||
611 | 986 | bug_message = bug_watch.addComment(comment_id, comment_message) | 988 | bug_message = bug_watch.addComment(comment_id, comment_message) |
612 | 987 | imported_comments.append(bug_message) | 989 | imported_comments.append(bug_message) |
There were several calls into code in the externalbugtracker module that passed BugWatch objects. Two things:
1. The *only* field of these BugWatch objects ever referenced is `remotebug`. I've changed all methods to accept a `remote_bug_id` parameter instead of `bug_watch`, and all call-sites have been updated accordingly.
2. These are database/model objects. There is a nascent plan to also package and run the externalbugtracker code as a job-running service, outside of the familiar core Launchpad application. It's much easier to pass/serialize a `remote_bug_id` parameter (always a string) into a job spec than a model object.
Lint free.
Test: bin/test -vvt 'checkwatch| bug-?watch| bug-?track| bug-?import| bug-?notificati on'