Merge lp:~allenap/launchpad/dont-pass-bugwatches-to-externalbugtracker into lp:launchpad

Proposed by Gavin Panella
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
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 ISupportsCommentmport. Previously bug watch objects were passed, but the external bug tracker code is meant to be independent of DB code, only the remotebug attribute was referenced in all cases, and methods in related interfaces all requested remote bug IDs rather than bug watches.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

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-?notification'

Revision history for this message
Michael Nelson (michael.nelson) wrote :

G'day Gavin,

All looks very straight forward. Just one tiny comment below.

> === modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
> --- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-12-23 10:49:55 +0000
> +++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2010-01-07 12:21:47 +0000
> @@ -406,7 +406,7 @@
> a given remote bug.
>
> >>> bugzilla.xmlrpc_transport.print_method_calls = True
> - >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch)
> + >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch.remotebug)
> CALLED Bug.comments({'ids': [1], 'include_fields': ['id']})
>
> >>> print sorted(bug_comment_ids)
> @@ -415,7 +415,7 @@
> getCommentIds() can only be called if initializeRemoteBugDB() has been
> called and the bug exists locally.
>
> - >>> bugzilla.getCommentIds(bug_watch_broken)
> + >>> bugzilla.getCommentIds(bug_watch_broken.remotebug)
> Traceback (most recent call last):
> ...
> BugNotFound: 42
> @@ -425,11 +425,11 @@
> ---------------
>
> ISupportsCommentImport.fetchComments() is the method used to fetch a
> -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).

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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 a given remote bug.
6
7 >>> bugzilla.xmlrpc_transport.print_method_calls = True
8- >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch)
9+ >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch.remotebug)
10 CALLED Bug.comments({'ids': [1], 'include_fields': ['id']})
11
12 >>> print sorted(bug_comment_ids)
13@@ -415,7 +415,7 @@
14 getCommentIds() can only be called if initializeRemoteBugDB() has been
15 called and the bug exists locally.
16
17- >>> bugzilla.getCommentIds(bug_watch_broken)
18+ >>> bugzilla.getCommentIds(bug_watch_broken.remotebug)
19 Traceback (most recent call last):
20 ...
21 BugNotFound: 42
22@@ -425,11 +425,11 @@
23 ---------------
24
25 ISupportsCommentImport.fetchComments() is the method used to fetch a
26-given set of comments from the remote bugtracker. It takes a bug watch
27-and a list of the comment IDs to retrieve for that bug watch.
28+given set of comments from the remote bugtracker. It takes a remote
29+bug ID and a list of the comment IDs to retrieve for that bug watch.
30
31 >>> bugzilla.xmlrpc_transport.print_method_calls = False
32- >>> bugzilla.fetchComments(bug_watch, ['1', '3'])
33+ >>> bugzilla.fetchComments(bug_watch.remotebug, ['1', '3'])
34
35 The comments will be stored in the bugs dict as a dict of comment id =>
36 comment dict mappings under the key 'comments'.
37@@ -459,7 +459,7 @@
38 fetchComments() will silently ignore them.
39
40 >>> bugzilla.xmlrpc_transport.print_method_calls = False
41- >>> bugzilla.fetchComments(bug_watch, ['1', '4'])
42+ >>> bugzilla.fetchComments(bug_watch.remotebug, ['1', '4'])
43
44 >>> comments = bugzilla._bugs[1]['comments']
45 >>> for comment_id in sorted(comments):
46@@ -482,8 +482,9 @@
47 ISupportsCommentImport.getPosterForComment() returns a tuple of
48 (displayname, email) for the author of a remote comment.
49
50- >>> bugzilla.fetchComments(bug_watch_two, ['2', '4'])
51- >>> displayname, email = bugzilla.getPosterForComment(bug_watch_two, '4')
52+ >>> bugzilla.fetchComments(bug_watch_two.remotebug, ['2', '4'])
53+ >>> displayname, email = bugzilla.getPosterForComment(
54+ ... bug_watch_two.remotebug, '4')
55 >>> print displayname, email
56 Ford Prefect ford.prefect@h2g2.com
57
58@@ -491,7 +492,8 @@
59 address then the method will return displayname = None and will return
60 the whole of the author's name in the email field.
61
62- >>> displayname, email = bugzilla.getPosterForComment(bug_watch_two, '2')
63+ >>> displayname, email = bugzilla.getPosterForComment(
64+ ... bug_watch_two.remotebug, '2')
65 >>> print displayname, email
66 None trillian
67
68@@ -500,13 +502,13 @@
69 ----------------------
70
71 ISupportsCommentImport.getMessageForComment() returns a Launchpad
72-IMessage instance for a given comment. It takes a bug watch, a comment
73-ID and a Person object generated from the return value of
74+IMessage instance for a given comment. It takes a remote bug ID, a
75+comment ID and a Person object generated from the return value of
76 getPosterForComment(), above. For the sake of this test we'll use
77 Sample Person as our poster.
78
79 >>> message = bugzilla.getMessageForComment(
80- ... bug_watch_two, '2', sample_person)
81+ ... bug_watch_two.remotebug, '2', sample_person)
82 >>> print message.text_contents
83 Bring the passengers to the bridge please Marvin.
84
85@@ -560,12 +562,12 @@
86 The comment will be stored on the remote server with the other comments.
87
88 >>> bugzilla.xmlrpc_transport.print_method_calls = False
89- >>> print sorted(bugzilla.getCommentIds(bug_watch))
90+ >>> print sorted(bugzilla.getCommentIds(bug_watch.remotebug))
91 ['1', '3', '5']
92
93- >>> bugzilla.fetchComments(bug_watch, ['5'])
94+ >>> bugzilla.fetchComments(bug_watch.remotebug, ['5'])
95 >>> message = bugzilla.getMessageForComment(
96- ... bug_watch, '5', sample_person)
97+ ... bug_watch.remotebug, '5', sample_person)
98 >>> print message.text_contents
99 This is a new remote comment.
100 <BLANKLINE>
101
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 comment IDs for a given bug on a remote bugtracker.
107
108 >>> bugzilla.xmlrpc_transport.print_method_calls = True
109- >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch)
110+ >>> bug_comment_ids = bugzilla.getCommentIds(bug_watch.remotebug)
111 CALLED Launchpad.comments({'bug_ids': [1], 'include_fields': ['id']})
112
113 >>> print sorted(bug_comment_ids)
114@@ -386,7 +386,7 @@
115 getCommentIds() can only be called if initializeRemoteBugDB() has been
116 called and the bug exists locally.
117
118- >>> bugzilla.getCommentIds(bug_watch_broken)
119+ >>> bugzilla.getCommentIds(bug_watch_broken.remotebug)
120 Traceback (most recent call last):
121 ...
122 BugNotFound: 42
123@@ -396,11 +396,11 @@
124 ---------------
125
126 ISupportsCommentImport.fetchComments() is the method used to fetch a
127-given set of comments from the remote bugtracker. It takes a bug watch
128-and a list of the comment IDs to retrieve for that bug watch.
129+given set of comments from the remote bugtracker. It takes a remote
130+bug ID and a list of the comment IDs to retrieve for that bug watch.
131
132 >>> bugzilla.xmlrpc_transport.print_method_calls = False
133- >>> bugzilla.fetchComments(bug_watch, ['1', '3'])
134+ >>> bugzilla.fetchComments(bug_watch.remotebug, ['1', '3'])
135
136 The comments will be stored in the bugs dict as a dict of comment id =>
137 comment dict mappings under the key 'comments'.
138@@ -466,11 +466,12 @@
139 The comment will be stored on the remote server with the other comments.
140
141 >>> bugzilla.xmlrpc_transport.print_method_calls = False
142- >>> print sorted(bugzilla.getCommentIds(bug_watch))
143+ >>> print sorted(bugzilla.getCommentIds(bug_watch.remotebug))
144 ['1', '3', '5']
145
146- >>> bugzilla.fetchComments(bug_watch, ['5'])
147- >>> message = bugzilla.getMessageForComment(bug_watch, '5', sample_person)
148+ >>> bugzilla.fetchComments(bug_watch.remotebug, ['5'])
149+ >>> message = bugzilla.getMessageForComment(
150+ ... bug_watch.remotebug, '5', sample_person)
151 >>> print message.text_contents
152 This is a new remote comment.
153 <BLANKLINE>
154
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 getCommentIds() will return a list of the comment IDs for a given remote
160 bug. DebBugs comment IDs are RFC822 message IDs.
161
162- >>> comment_ids = external_debbugs.getCommentIds(bug_watch)
163+ >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug)
164 >>> print comment_ids
165 ['<20040309081430.98BF411EE67@tux>']
166
167@@ -371,7 +371,7 @@
168 >>> external_debbugs.debbugs_db._data_file = (
169 ... 'debbugs-comment-with-no-date.txt')
170
171- >>> comment_ids = external_debbugs.getCommentIds(bug_watch)
172+ >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug)
173 >>> print comment_ids
174 []
175
176@@ -396,7 +396,7 @@
177
178 However, getCommentIds() will only return the comment ID once.
179
180- >>> comment_ids = external_debbugs.getCommentIds(bug_watch)
181+ >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug)
182 >>> print comment_ids
183 ['<20040309081430.98BF411EE67@tux>']
184
185@@ -412,7 +412,7 @@
186
187 >>> comment_id = comment_ids[0]
188 >>> poster_name, poster_email = external_debbugs.getPosterForComment(
189- ... bug_watch, comment_id)
190+ ... bug_watch.remotebug, comment_id)
191 >>> print "%s <%s>" % (poster_name, poster_email)
192 Teun Vink <teun@tux.office.luna.net>
193
194@@ -427,7 +427,7 @@
195 ... comment='when importing comments for %s.' % bug_watch.title)
196
197 >>> message = external_debbugs.getMessageForComment(
198- ... bug_watch, comment_id, poster)
199+ ... bug_watch.remotebug, comment_id, poster)
200
201 >>> print message.owner.displayname
202 Teun Vink
203@@ -445,13 +445,13 @@
204 >>> external_debbugs.debbugs_db._data_file = (
205 ... 'debbugs-comment-with-received-date.txt')
206
207- >>> comment_ids = external_debbugs.getCommentIds(bug_watch)
208+ >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug)
209 >>> print comment_ids
210 ['<yetanothermessageid@launchpad>']
211
212 >>> external_debbugs.fetchComments(bug_watch, comment_ids)
213 >>> message = external_debbugs.getMessageForComment(
214- ... bug_watch, comment_ids[0], poster)
215+ ... bug_watch.remotebug, comment_ids[0], poster)
216
217 >>> print message.datecreated
218 2008-05-30 21:18:12+00:00
219@@ -477,11 +477,11 @@
220 >>> external_debbugs.debbugs_db._data_file = (
221 ... 'debbugs-comment-with-no-useful-received-date.txt')
222
223- >>> comment_ids = external_debbugs.getCommentIds(bug_watch)
224+ >>> comment_ids = external_debbugs.getCommentIds(bug_watch.remotebug)
225
226 >>> external_debbugs.fetchComments(bug_watch, comment_ids)
227 >>> message = external_debbugs.getMessageForComment(
228- ... bug_watch, comment_ids[0], poster)
229+ ... bug_watch.remotebug, comment_ids[0], poster)
230
231 >>> print message.datecreated
232 2007-12-14 18:54:30+00:00
233
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 >>> commit()
239 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
240
241-getCommentIds() returns all the comment IDs for a given bug watch.
242+getCommentIds() returns all the comment IDs for a given remote bug.
243 bug_watch is against remote bug 1, which has one comment.
244
245 >>> test_transport.expireCookie(test_transport.auth_cookie)
246@@ -371,23 +371,23 @@
247 Using XML-RPC to generate token.
248 Successfully validated the token.
249
250- >>> trac.getCommentIds(bug_watch)
251+ >>> trac.getCommentIds(bug_watch.remotebug)
252 ['1-1']
253
254 bug_watch_two is against remote bug 2, which has two comments.
255
256- >>> trac.getCommentIds(bug_watch_two)
257+ >>> trac.getCommentIds(bug_watch_two.remotebug)
258 ['2-1', '2-2']
259
260 bug_watch_three is against bug 3, which has no comments.
261
262- >>> trac.getCommentIds(bug_watch_three)
263+ >>> trac.getCommentIds(bug_watch_three.remotebug)
264 []
265
266 Trying to call getCommentIds() on a bug that doesn't exist will raise a
267 BugNotFound error.
268
269- >>> trac.getCommentIds(bug_watch_broken)
270+ >>> trac.getCommentIds(bug_watch_broken.remotebug)
271 Traceback (most recent call last):
272 ...
273 BugNotFound: 123
274@@ -406,7 +406,7 @@
275 parsed.
276
277 >>> test_transport.expireCookie(test_transport.auth_cookie)
278- >>> trac.fetchComments(bug_watch, ['1-1'])
279+ >>> trac.fetchComments(bug_watch.remotebug, ['1-1'])
280 Using XML-RPC to generate token.
281 Successfully validated the token.
282
283@@ -422,7 +422,7 @@
284 getPosterForComment() returns a tuple of (displayname, emailaddress) for
285 the poster of a given comment.
286
287- >>> trac.getPosterForComment(bug_watch, '1-1')
288+ >>> trac.getPosterForComment(bug_watch.remotebug, '1-1')
289 ('Test', 'test@canonical.com')
290
291 getPosterForComment() handles situations in which only an email address
292@@ -430,8 +430,8 @@
293 displayname. When this is passed to IPersonSet.ensurePerson() a display
294 name will be generated for the user from their email address.
295
296- >>> trac.fetchComments(bug_watch_two, ['2-1', '2-2'])
297- >>> trac.getPosterForComment(bug_watch_two, '2-1')
298+ >>> trac.fetchComments(bug_watch_two.remotebug, ['2-1', '2-2'])
299+ >>> trac.getPosterForComment(bug_watch_two.remotebug, '2-1')
300 (None, 'test@canonical.com')
301
302 getPosterForComment() will also return displayname, email tuples in
303@@ -439,7 +439,7 @@
304 However, in these cases it is the email address that will be set to
305 None.
306
307- >>> trac.getPosterForComment(bug_watch_two, '2-2')
308+ >>> trac.getPosterForComment(bug_watch_two.remotebug, '2-2')
309 ('foo.bar', None)
310
311 Finally, getMessageForComment() will return a Message instance for a
312@@ -448,7 +448,8 @@
313
314 >>> from zope.component import getUtility
315 >>> poster = getUtility(IPersonSet).getByEmail('test@canonical.com')
316- >>> message_one = trac.getMessageForComment(bug_watch, '1-1', poster)
317+ >>> message_one = trac.getMessageForComment(
318+ ... bug_watch.remotebug, '1-1', poster)
319
320 The Message returned by getMessageForComment() contains the full text of
321 the original comment.
322
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
328 return bug_products
329
330- def getCommentIds(self, bug_watch):
331+ def getCommentIds(self, remote_bug_id):
332 """See `ISupportsCommentImport`."""
333- actual_bug_id = self._getActualBugId(bug_watch.remotebug)
334+ actual_bug_id = self._getActualBugId(remote_bug_id)
335
336 # Check that the bug exists, first.
337 if actual_bug_id not in self._bugs:
338- raise BugNotFound(bug_watch.remotebug)
339+ raise BugNotFound(remote_bug_id)
340
341 # Get only the remote comment IDs and store them in the
342 # 'comments' field of the bug.
343@@ -648,9 +648,9 @@
344
345 return [str(comment['id']) for comment in bug_comments]
346
347- def fetchComments(self, bug_watch, comment_ids):
348+ def fetchComments(self, remote_bug_id, comment_ids):
349 """See `ISupportsCommentImport`."""
350- actual_bug_id = self._getActualBugId(bug_watch.remotebug)
351+ actual_bug_id = self._getActualBugId(remote_bug_id)
352
353 # We need to cast comment_ids to integers, since
354 # BugWatchUpdater.importBugComments() will pass us a list of
355@@ -664,7 +664,7 @@
356 comments = return_dict['comments']
357
358 # As a sanity check, drop any comments that don't belong to the
359- # bug in bug_watch.
360+ # bug in remote_bug_id.
361 for comment_id, comment in comments.items():
362 if int(comment['bug_id']) != actual_bug_id:
363 del comments[comment_id]
364@@ -674,9 +674,9 @@
365 (int(id), comments[id]) for id in comments)
366 self._bugs[actual_bug_id]['comments'] = comments_with_int_ids
367
368- def getPosterForComment(self, bug_watch, comment_id):
369+ def getPosterForComment(self, remote_bug_id, comment_id):
370 """See `ISupportsCommentImport`."""
371- actual_bug_id = self._getActualBugId(bug_watch.remotebug)
372+ actual_bug_id = self._getActualBugId(remote_bug_id)
373
374 # We need to cast comment_id to integers, since
375 # BugWatchUpdater.importBugComments() will pass us a string (see
376@@ -693,9 +693,9 @@
377
378 return (display_name, email)
379
380- def getMessageForComment(self, bug_watch, comment_id, poster):
381+ def getMessageForComment(self, remote_bug_id, comment_id, poster):
382 """See `ISupportsCommentImport`."""
383- actual_bug_id = self._getActualBugId(bug_watch.remotebug)
384+ actual_bug_id = self._getActualBugId(remote_bug_id)
385
386 # We need to cast comment_id to integers, since
387 # BugWatchUpdater.importBugComments() will pass us a string (see
388@@ -845,13 +845,13 @@
389 server_utc_time = time_dict['utc_time']
390 return server_utc_time.replace(tzinfo=pytz.timezone('UTC'))
391
392- def getCommentIds(self, bug_watch):
393+ def getCommentIds(self, remote_bug_id):
394 """See `ISupportsCommentImport`."""
395- actual_bug_id = self._getActualBugId(bug_watch.remotebug)
396+ actual_bug_id = self._getActualBugId(remote_bug_id)
397
398 # Check that the bug exists, first.
399 if actual_bug_id not in self._bugs:
400- raise BugNotFound(bug_watch.remotebug)
401+ raise BugNotFound(remote_bug_id)
402
403 # Get only the remote comment IDs and store them in the
404 # 'comments' field of the bug.
405@@ -871,9 +871,9 @@
406 # bug 248938).
407 return [str(comment['id']) for comment in bug_comments]
408
409- def fetchComments(self, bug_watch, comment_ids):
410+ def fetchComments(self, remote_bug_id, comment_ids):
411 """See `ISupportsCommentImport`."""
412- actual_bug_id = self._getActualBugId(bug_watch.remotebug)
413+ actual_bug_id = self._getActualBugId(remote_bug_id)
414
415 # We need to cast comment_ids to integers, since
416 # BugWatchUpdater.importBugComments() will pass us a list of
417
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 debian_bug = self._findBug(remote_bug)
423 return debian_bug.subject, debian_bug.description
424
425- def getCommentIds(self, bug_watch):
426+ def getCommentIds(self, remote_bug_id):
427 """See `ISupportsCommentImport`."""
428- debian_bug = self._findBug(bug_watch.remotebug)
429+ debian_bug = self._findBug(remote_bug_id)
430 self._loadLog(debian_bug)
431
432 comment_ids = []
433@@ -244,16 +244,16 @@
434
435 return comment_ids
436
437- def fetchComments(self, bug_watch, comment_ids):
438+ def fetchComments(self, remote_bug_id, comment_ids):
439 """See `ISupportsCommentImport`."""
440 # This method does nothing since DebBugs bugs are stored locally
441 # and their comments don't need to be pre-fetched. It exists
442 # purely to ensure that BugWatchUpdater doesn't choke on it.
443 pass
444
445- def getPosterForComment(self, bug_watch, comment_id):
446+ def getPosterForComment(self, remote_bug_id, comment_id):
447 """See `ISupportsCommentImport`."""
448- debian_bug = self._findBug(bug_watch.remotebug)
449+ debian_bug = self._findBug(remote_bug_id)
450 self._loadLog(debian_bug)
451
452 for comment in debian_bug.comments:
453@@ -304,9 +304,9 @@
454
455 return msg_date
456
457- def getMessageForComment(self, bug_watch, comment_id, poster):
458+ def getMessageForComment(self, remote_bug_id, comment_id, poster):
459 """See `ISupportsCommentImport`."""
460- debian_bug = self._findBug(bug_watch.remotebug)
461+ debian_bug = self._findBug(remote_bug_id)
462 self._loadLog(debian_bug)
463
464 for comment in debian_bug.comments:
465
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
471 return [bug['id'] for bug in modified_bugs]
472
473- def getCommentIds(self, bug_watch):
474+ def getCommentIds(self, remote_bug_id):
475 """See `ISupportsCommentImport`."""
476 try:
477- bug = self.bugs[int(bug_watch.remotebug)]
478+ bug = self.bugs[int(remote_bug_id)]
479 except KeyError:
480- raise BugNotFound(bug_watch.remotebug)
481+ raise BugNotFound(remote_bug_id)
482 else:
483 return [comment_id for comment_id in bug['comments']]
484
485 @needs_authentication
486- def fetchComments(self, bug_watch, comment_ids):
487+ def fetchComments(self, remote_bug_id, comment_ids):
488 """See `ISupportsCommentImport`."""
489 bug_comments = {}
490
491@@ -402,11 +402,11 @@
492 # Finally, we overwrite the bug's comments field with the
493 # bug_comments dict. The nice upshot of this is that we can
494 # still loop over the dict and get IDs back.
495- self.bugs[int(bug_watch.remotebug)]['comments'] = bug_comments
496+ self.bugs[int(remote_bug_id)]['comments'] = bug_comments
497
498- def getPosterForComment(self, bug_watch, comment_id):
499+ def getPosterForComment(self, remote_bug_id, comment_id):
500 """See `ISupportsCommentImport`."""
501- bug = self.bugs[int(bug_watch.remotebug)]
502+ bug = self.bugs[int(remote_bug_id)]
503 comment = bug['comments'][comment_id]
504
505 display_name, email = parseaddr(comment['user'])
506@@ -424,9 +424,9 @@
507 else:
508 return display_name, email
509
510- def getMessageForComment(self, bug_watch, comment_id, poster):
511+ def getMessageForComment(self, remote_bug_id, comment_id, poster):
512 """See `ISupportsCommentImport`."""
513- bug = self.bugs[int(bug_watch.remotebug)]
514+ bug = self.bugs[int(remote_bug_id)]
515 comment = bug['comments'][comment_id]
516
517 comment_datecreated = datetime.fromtimestamp(
518
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 class ISupportsCommentImport(IExternalBugTracker):
524 """An external bug tracker that supports comment imports."""
525
526- def fetchComments(bug_watch, comment_ids):
527+ def fetchComments(remote_bug_id, comment_ids):
528 """Load a given set of remote comments, ready for parsing.
529
530- :param bug_watch: The bug watch for which to fetch the comments.
531+ :param remote_bug_id: The ID of the remote bug from which to
532+ fetch comments.
533+ :type remote_bug_id: See `IBugWatch.remotebug`.
534 :param comment_ids: A list of the IDs of the comments to load.
535 """
536
537- def getCommentIds(bug_watch):
538+ def getCommentIds(remote_bug_id):
539 """Return all the comment IDs for a given remote bug.
540
541- :param bug_watch: An `IBugWatch` pointing to the remote bug from
542- which comments should be imported.
543+ :param remote_bug_id: The ID of the remote bug from which
544+ comments should be imported.
545+ :type remote_bug_id: See `IBugWatch.remotebug`.
546 :return: A list of strings, each of which is the ID of one
547 comment on the remote bug.
548 """
549
550- def getPosterForComment(bug_watch, comment_id):
551+ def getPosterForComment(remote_bug_id, comment_id):
552 """Return a tuple of (name, emailaddress) for a comment's poster.
553
554- :param bug_watch: An `IBugWatch` pointing to the remote bug from
555- which comments should be imported.
556+ :param remote_bug_id: The ID of the remote bug from which
557+ comments have been imported.
558+ :type remote_bug_id: See `IBugWatch.remotebug`.
559 :param comment_id: A string representing the remote comment ID
560 from which the poster's details should be extracted.
561 """
562
563- def getMessageForComment(bug_watch, comment_id, poster):
564+ def getMessageForComment(remote_bug_id, comment_id, poster):
565 """Return an `IMessage` instance for a comment.
566
567- :param bug_watch: An `IBugWatch` pointing to the remote bug from
568- which comments should be imported.
569+ :param remote_bug_id: The ID of the remote bug from which
570+ comments have been imported.
571+ :type remote_bug_id: See `IBugWatch.remotebug`.
572 :param comment_id: A string representing the remote comment ID
573 from which the returned `IMessage` should be created.
574 """
575
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 """
581 # Construct a list of the comment IDs we want to import; i.e.
582 # those which we haven't already imported.
583- all_comment_ids = external_bugtracker.getCommentIds(bug_watch)
584+ all_comment_ids = external_bugtracker.getCommentIds(
585+ bug_watch.remotebug)
586 comment_ids_to_import = [
587 comment_id for comment_id in all_comment_ids
588 if not bug_watch.hasComment(comment_id)]
589
590- external_bugtracker.fetchComments(bug_watch, comment_ids_to_import)
591+ external_bugtracker.fetchComments(
592+ bug_watch.remotebug, comment_ids_to_import)
593
594 previous_imported_comments = bug_watch.getImportedBugMessages()
595 is_initial_import = previous_imported_comments.count() == 0
596 imported_comments = []
597 for comment_id in comment_ids_to_import:
598 displayname, email = external_bugtracker.getPosterForComment(
599- bug_watch, comment_id)
600+ bug_watch.remotebug, comment_id)
601
602 if displayname is None and email is None:
603 # If we don't have a displayname or an email address
604@@ -981,7 +983,7 @@
605 "when importing comments for %s." % bug_watch.title)
606
607 comment_message = external_bugtracker.getMessageForComment(
608- bug_watch, comment_id, poster)
609+ bug_watch.remotebug, comment_id, poster)
610
611 bug_message = bug_watch.addComment(comment_id, comment_message)
612 imported_comments.append(bug_message)