Merge lp:~wgrant/launchpad/destroy-bugtask-markers into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 13492
Proposed branch: lp:~wgrant/launchpad/destroy-bugtask-markers
Merge into: lp:launchpad
Prerequisite: lp:~wgrant/launchpad/unuse-bugtask-markers
Diff against target: 591 lines (+39/-161)
12 files modified
lib/canonical/launchpad/mail/commands.py (+2/-2)
lib/lp/bugs/doc/bug.txt (+2/-2)
lib/lp/bugs/doc/bugactivity.txt (+3/-4)
lib/lp/bugs/doc/bugnotifications.txt (+3/-4)
lib/lp/bugs/doc/bugtask.txt (+0/-3)
lib/lp/bugs/doc/initial-bug-contacts.txt (+6/-9)
lib/lp/bugs/doc/malone-karma.txt (+9/-13)
lib/lp/bugs/doc/security-teams.txt (+2/-2)
lib/lp/bugs/interfaces/bugtask.py (+0/-42)
lib/lp/bugs/model/bugtask.py (+10/-65)
lib/lp/bugs/model/tests/test_bugtask.py (+0/-12)
lib/lp/bugs/tests/test_bugnotification.py (+2/-3)
To merge this branch: bzr merge lp:~wgrant/launchpad/destroy-bugtask-markers
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+68637@code.launchpad.net

Commit message

[r=sinzui][bug=55089,80902][incr] Destroy the I*BugTask marker interfaces.

Description of the change

This branch destroys the I*BugTask marker interfaces.

Users are stripped from lp.bugs.model.bugtask, _init is no longer overridden to add them, tonnes of tests have been updated to use IBugTask instead, and the interfaces themselves have been removed.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

That you so much for doing this.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/mail/commands.py'
2--- lib/canonical/launchpad/mail/commands.py 2011-05-12 21:33:10 +0000
3+++ lib/canonical/launchpad/mail/commands.py 2011-07-22 04:38:51 +0000
4@@ -57,7 +57,7 @@
5 from lp.bugs.interfaces.bugtask import (
6 BugTaskImportance,
7 BugTaskStatus,
8- IDistroBugTask,
9+ IBugTask,
10 )
11 from lp.bugs.interfaces.cve import ICveSet
12 from lp.registry.interfaces.distribution import IDistribution
13@@ -642,7 +642,7 @@
14 bugtask = bug.getBugTask(bug_target.distribution)
15 if bugtask is not None:
16 bugtask_before_edit = Snapshot(
17- bugtask, providing=IDistroBugTask)
18+ bugtask, providing=IBugTask)
19 bugtask.sourcepackagename = bug_target.sourcepackagename
20 event = ObjectModifiedEvent(
21 bugtask, bugtask_before_edit, ['sourcepackagename'])
22
23=== modified file 'lib/lp/bugs/doc/bug.txt'
24--- lib/lp/bugs/doc/bug.txt 2011-06-29 09:04:14 +0000
25+++ lib/lp/bugs/doc/bug.txt 2011-07-22 04:38:51 +0000
26@@ -601,7 +601,7 @@
27 Modifying a bugtask will update IBug.date_last_updated.
28
29 >>> from lp.bugs.interfaces.bugtask import (
30- ... BugTaskImportance, BugTaskStatus, IUpstreamBugTask)
31+ ... BugTaskImportance, BugTaskStatus, IBugTask)
32
33 >>> firefox_task = firefox_bug.bugtasks[0]
34
35@@ -614,7 +614,7 @@
36 New
37
38 >>> bugtask_before_modification = Snapshot(
39- ... firefox_task, providing=IUpstreamBugTask)
40+ ... firefox_task, providing=IBugTask)
41
42 >>> firefox_task.transitionToImportance(
43 ... BugTaskImportance.CRITICAL, current_user())
44
45=== modified file 'lib/lp/bugs/doc/bugactivity.txt'
46--- lib/lp/bugs/doc/bugactivity.txt 2011-02-17 17:23:06 +0000
47+++ lib/lp/bugs/doc/bugactivity.txt 2011-07-22 04:38:51 +0000
48@@ -25,9 +25,8 @@
49 >>> from lazr.lifecycle.event import ObjectModifiedEvent
50 >>> from lazr.lifecycle.snapshot import Snapshot
51 >>> from lp.bugs.interfaces.bugtask import (
52+ ... IBugTask,
53 ... IBugTaskSet,
54- ... IDistroBugTask,
55- ... IUpstreamBugTask,
56 ... )
57 >>> from lp.registry.interfaces.product import IProductSet
58 >>> user = getUtility(ILaunchBag).user
59@@ -87,7 +86,7 @@
60 ... "distribution", "sourcepackagename", "milestone", "status",
61 ... "importance", "assignee", "bugwatch"]
62 >>> old_source_package_assignment = Snapshot(
63- ... source_package_assignment, providing=IDistroBugTask)
64+ ... source_package_assignment, providing=IBugTask)
65 >>> source_package_assignment.transitionToStatus(
66 ... BugTaskStatus.CONFIRMED, getUtility(ILaunchBag).user)
67 >>> source_package_assignment_edited = ObjectModifiedEvent(
68@@ -135,7 +134,7 @@
69 ... "product", "milestone", "status", "assignee", "bugwatch",
70 ... "importance"]
71 >>> old_product_assignment = Snapshot(
72- ... product_assignment, providing=IUpstreamBugTask)
73+ ... product_assignment, providing=IBugTask)
74 >>> product_assignment.transitionToStatus(
75 ... BugTaskStatus.INVALID, getUtility(ILaunchBag).user)
76 >>> product_assignment_edited = ObjectModifiedEvent(
77
78=== modified file 'lib/lp/bugs/doc/bugnotifications.txt'
79--- lib/lp/bugs/doc/bugnotifications.txt 2011-02-11 22:04:25 +0000
80+++ lib/lp/bugs/doc/bugnotifications.txt 2011-07-22 04:38:51 +0000
81@@ -229,11 +229,11 @@
82 >>> from lazr.lifecycle.snapshot import Snapshot
83 >>> from lp.bugs.interfaces.bugtask import (
84 ... BugTaskStatus,
85- ... IDistroBugTask,
86+ ... IBugTask,
87 ... )
88
89 >>> bugtask_before_modification = Snapshot(
90- ... firefox_crashes_in_debian, providing=IDistroBugTask)
91+ ... firefox_crashes_in_debian, providing=IBugTask)
92 >>> firefox_crashes_in_debian.transitionToStatus(
93 ... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
94 >>> firefox_crashes_in_debian.transitionToAssignee(bug_submitter)
95@@ -252,9 +252,8 @@
96 ** Changed in: mozilla-firefox (Debian)
97 ...
98
99- >>> from lp.bugs.interfaces.bugtask import IProductSeriesBugTask
100 >>> bugtask_before_modification = Snapshot(
101- ... firefox_crashes_in_trunk, providing=IProductSeriesBugTask)
102+ ... firefox_crashes_in_trunk, providing=IBugTask)
103 >>> firefox_crashes_in_trunk.transitionToStatus(
104 ... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
105 >>> firefox_crashes_in_trunk.transitionToAssignee(bug_submitter)
106
107=== modified file 'lib/lp/bugs/doc/bugtask.txt'
108--- lib/lp/bugs/doc/bugtask.txt 2011-07-21 06:44:22 +0000
109+++ lib/lp/bugs/doc/bugtask.txt 2011-07-22 04:38:51 +0000
110@@ -103,15 +103,12 @@
111
112 * a product series
113
114- >>> from lp.bugs.interfaces.bugtask import IProductSeriesBugTask
115
116 >>> firefox = productset['firefox']
117 >>> firefox_1_0 = firefox.getSeries("1.0")
118
119 >>> productseries_task = bugtaskset.createTask(
120 ... owner=mark, bug=bug_one, productseries=firefox_1_0)
121- >>> IProductSeriesBugTask.providedBy(productseries_task)
122- True
123
124 >>> productseries_task.target == firefox_1_0
125 True
126
127=== modified file 'lib/lp/bugs/doc/initial-bug-contacts.txt'
128--- lib/lp/bugs/doc/initial-bug-contacts.txt 2011-03-23 16:28:51 +0000
129+++ lib/lp/bugs/doc/initial-bug-contacts.txt 2011-07-22 04:38:51 +0000
130@@ -120,7 +120,7 @@
131 >>> import transaction
132 >>> from lazr.lifecycle.event import ObjectModifiedEvent
133 >>> from lazr.lifecycle.snapshot import Snapshot
134- >>> from lp.bugs.interfaces.bugtask import IDistroBugTask
135+ >>> from lp.bugs.interfaces.bugtask import IBugTask
136 >>> from lp.services.mail import stub
137
138 >>> daf = personset.getByName("daf")
139@@ -130,7 +130,7 @@
140 <...StructuralSubscription object at ...>
141
142 >>> old_state = Snapshot(
143- ... bug_one_in_ubuntu_firefox, providing=IDistroBugTask)
144+ ... bug_one_in_ubuntu_firefox, providing=IBugTask)
145
146 >>> bug_one_in_ubuntu_firefox.sourcepackagename = (
147 ... ubuntu_pmount.sourcepackagename)
148@@ -223,7 +223,7 @@
149 package to None.
150
151 >>> old_state = Snapshot(
152- ... bug_one_in_ubuntu_firefox, providing=IDistroBugTask)
153+ ... bug_one_in_ubuntu_firefox, providing=IBugTask)
154
155 >>> bug_one_in_ubuntu_firefox.sourcepackagename = None
156
157@@ -250,7 +250,7 @@
158 <...StructuralSubscription object at ...>
159
160 >>> old_state = Snapshot(
161- ... bug_one_in_ubuntu_firefox, providing=IDistroBugTask)
162+ ... bug_one_in_ubuntu_firefox, providing=IBugTask)
163
164 >>> bug_one_in_ubuntu_firefox.sourcepackagename = (
165 ... ubuntu_pmount.sourcepackagename)
166@@ -284,7 +284,7 @@
167 and then the bug gets reassigned to mozilla firefox:
168
169 >>> old_state = Snapshot(
170- ... bug_one_in_ubuntu_firefox, providing=IDistroBugTask)
171+ ... bug_one_in_ubuntu_firefox, providing=IBugTask)
172
173 >>> bug_one_in_ubuntu_firefox.sourcepackagename = (
174 ... ubuntu_firefox.sourcepackagename)
175@@ -322,8 +322,6 @@
176 Then we'll reassign bug #2 in Ubuntu to be in Firefox, noting that Foo
177 Bar gets subscribed to the bug in the process:
178
179- >>> from lp.bugs.interfaces.bugtask import IUpstreamBugTask
180-
181 >>> bug_two_in_ubuntu = getUtility(IBugTaskSet).get(3)
182 >>> print bug_two_in_ubuntu.bug.id
183 2
184@@ -335,8 +333,7 @@
185 ... bug_two_in_ubuntu.bug.subscriptions])
186 [u'Steve Alexander']
187
188- >>> old_state = Snapshot(
189- ... bug_two_in_ubuntu, providing=IUpstreamBugTask)
190+ >>> old_state = Snapshot(bug_two_in_ubuntu, providing=IBugTask)
191
192 >>> bug_two_in_ubuntu.product = mozilla_firefox
193
194
195=== modified file 'lib/lp/bugs/doc/malone-karma.txt'
196--- lib/lp/bugs/doc/malone-karma.txt 2010-12-02 16:13:51 +0000
197+++ lib/lp/bugs/doc/malone-karma.txt 2011-07-22 04:38:51 +0000
198@@ -74,10 +74,10 @@
199
200 >>> from lp.bugs.interfaces.bugtask import (
201 ... BugTaskStatus,
202- ... IDistroBugTask,
203+ ... IBugTask,
204 ... )
205 >>> bugtask = bug.bugtasks[0]
206- >>> old_bugtask = Snapshot(bugtask, providing=IDistroBugTask)
207+ >>> old_bugtask = Snapshot(bugtask, providing=IBugTask)
208 >>> bugtask.transitionToStatus(
209 ... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
210 >>> notify(ObjectModifiedEvent(bugtask, old_bugtask, ['status']))
211@@ -85,13 +85,11 @@
212
213 Mark a bug task as fixed when it is assigned awards the karma to the assignee:
214
215- >>> from lp.bugs.interfaces.bugtask import IUpstreamBugTask
216-
217 >>> ufo_product = factory.makeProduct(name='ufo')
218 >>> assignee = factory.makePerson(name='assignee')
219 >>> assigned_bugtask = factory.makeBugTask(bug=bug, target=ufo_product)
220 >>> assigned_bugtask.transitionToAssignee(assignee)
221- >>> old_bugtask = Snapshot(assigned_bugtask, providing=IUpstreamBugTask)
222+ >>> old_bugtask = Snapshot(assigned_bugtask, providing=IBugTask)
223 >>> assigned_bugtask.transitionToStatus(
224 ... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
225 >>> notify(ObjectModifiedEvent(assigned_bugtask, old_bugtask, ['status']))
226@@ -103,7 +101,7 @@
227
228 Reject a bug task:
229
230- >>> old_bugtask = Snapshot(bugtask, providing=IDistroBugTask)
231+ >>> old_bugtask = Snapshot(bugtask, providing=IBugTask)
232 >>> bugtask.transitionToStatus(
233 ... BugTaskStatus.INVALID, bugtask.target.owner)
234 >>> notify(ObjectModifiedEvent(bugtask, old_bugtask, ['status']))
235@@ -111,7 +109,7 @@
236
237 User accept a bug task:
238
239- >>> old_bugtask = Snapshot(bugtask, providing=IDistroBugTask)
240+ >>> old_bugtask = Snapshot(bugtask, providing=IBugTask)
241 >>> bugtask.transitionToStatus(
242 ... BugTaskStatus.CONFIRMED, getUtility(ILaunchBag).user)
243 >>> notify(ObjectModifiedEvent(bugtask, old_bugtask, ['status']))
244@@ -120,7 +118,7 @@
245 Driver accept a bug task:
246
247 >>> login_person(bugtask.target.owner)
248- >>> old_bugtask = Snapshot(bugtask, providing=IDistroBugTask)
249+ >>> old_bugtask = Snapshot(bugtask, providing=IBugTask)
250 >>> bugtask.transitionToStatus(
251 ... BugTaskStatus.TRIAGED, getUtility(ILaunchBag).user)
252 >>> notify(ObjectModifiedEvent(bugtask, old_bugtask, ['status']))
253@@ -134,7 +132,7 @@
254 >>> bugtask.transitionToImportance(
255 ... BugTaskImportance.HIGH, getUtility(ILaunchBag).user)
256 >>> for importance in BugTaskImportance.items:
257- ... old_bugtask = Snapshot(bugtask, providing=IDistroBugTask)
258+ ... old_bugtask = Snapshot(bugtask, providing=IBugTask)
259 ... bugtask.transitionToImportance(
260 ... importance, getUtility(ILaunchBag).user)
261 ... print importance.name
262@@ -184,9 +182,8 @@
263
264 >>> debian_woody_task.transitionToStatus(
265 ... BugTaskStatus.NEW, getUtility(ILaunchBag).user)
266- >>> from lp.bugs.interfaces.bugtask import IDistroSeriesBugTask
267 >>> old_bugtask = Snapshot(
268- ... debian_woody_task, providing=IDistroSeriesBugTask)
269+ ... debian_woody_task, providing=IBugTask)
270 >>> debian_woody_task.transitionToStatus(
271 ... BugTaskStatus.CONFIRMED, getUtility(ILaunchBag).user)
272 >>> notify(ObjectModifiedEvent(debian_woody_task, old_bugtask, ['status']))
273@@ -196,9 +193,8 @@
274
275 >>> evolution_trunk_task.transitionToStatus(
276 ... BugTaskStatus.NEW, getUtility(ILaunchBag).user)
277- >>> from lp.bugs.interfaces.bugtask import IProductSeriesBugTask
278 >>> old_bugtask = Snapshot(
279- ... evolution_trunk_task, providing=IProductSeriesBugTask)
280+ ... evolution_trunk_task, providing=IBugTask)
281 >>> evolution_trunk_task.transitionToStatus(
282 ... BugTaskStatus.CONFIRMED, getUtility(ILaunchBag).user)
283 >>> notify(ObjectModifiedEvent(
284
285=== modified file 'lib/lp/bugs/doc/security-teams.txt'
286--- lib/lp/bugs/doc/security-teams.txt 2011-03-17 03:03:33 +0000
287+++ lib/lp/bugs/doc/security-teams.txt 2011-07-22 04:38:51 +0000
288@@ -227,9 +227,9 @@
289 >>> from zope.event import notify
290 >>> from lazr.lifecycle.event import ObjectModifiedEvent
291 >>> from lazr.lifecycle.snapshot import Snapshot
292- >>> from lp.bugs.interfaces.bugtask import IUpstreamBugTask
293+ >>> from lp.bugs.interfaces.bugtask import IBugTask
294
295- >>> old_state = Snapshot(bug_in_evolution, providing=IUpstreamBugTask)
296+ >>> old_state = Snapshot(bug_in_evolution, providing=IBugTask)
297 >>> bug_in_evolution.product = thunderbird
298 >>> bug_product_changed = ObjectModifiedEvent(
299 ... bug_in_evolution, old_state, ["product"])
300
301=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
302--- lib/lp/bugs/interfaces/bugtask.py 2011-06-21 01:34:08 +0000
303+++ lib/lp/bugs/interfaces/bugtask.py 2011-07-22 04:38:51 +0000
304@@ -25,14 +25,10 @@
305 'IBugTaskSearch',
306 'IBugTaskSet',
307 'ICreateQuestionFromBugTaskForm',
308- 'IDistroBugTask',
309- 'IDistroSeriesBugTask',
310 'IFrontPageBugTaskSearch',
311 'INominationsReviewTableBatchNavigator',
312 'IPersonBugTaskSearch',
313- 'IProductSeriesBugTask',
314 'IRemoveQuestionFromBugTaskForm',
315- 'IUpstreamBugTask',
316 'IUpstreamProductBugTaskSearch',
317 'IllegalRelatedBugTasksParams',
318 'IllegalTarget',
319@@ -831,9 +827,6 @@
320 def getDelta(old_task):
321 """Compute the delta from old_task to this task.
322
323- old_task and this task are either both IDistroBugTask's or both
324- IUpstreamBugTask's, otherwise a TypeError is raised.
325-
326 Returns an IBugTaskDelta or None if there were no changes between
327 old_task and this task.
328 """
329@@ -1077,41 +1070,6 @@
330 milestone = Attribute("The milestone for which this task is scheduled.")
331
332
333-class IUpstreamBugTask(IBugTask):
334- """A bug needing fixing in a product."""
335- # XXX Brad Bollenbach 2006-08-03 bugs=55089:
336- # This interface should be renamed.
337- product = Choice(title=_('Project'), required=True, vocabulary='Product')
338-
339-
340-class IDistroBugTask(IBugTask):
341- """A bug needing fixing in a distribution, possibly a specific package."""
342- sourcepackagename = Choice(
343- title=_("Source Package Name"), required=False,
344- description=_("The source package in which the bug occurs. "
345- "Leave blank if you are not sure."),
346- vocabulary='SourcePackageName')
347- distribution = Choice(
348- title=_("Distribution"), required=True, vocabulary='Distribution')
349-
350-
351-class IDistroSeriesBugTask(IBugTask):
352- """A bug needing fixing in a distrorelease, or a specific package."""
353- sourcepackagename = Choice(
354- title=_("Source Package Name"), required=True,
355- vocabulary='SourcePackageName')
356- distroseries = Choice(
357- title=_("Series"), required=True,
358- vocabulary='DistroSeries')
359-
360-
361-class IProductSeriesBugTask(IBugTask):
362- """A bug needing fixing a productseries."""
363- productseries = Choice(
364- title=_("Series"), required=True,
365- vocabulary='ProductSeries')
366-
367-
368 class BugTaskSearchParams:
369 """Encapsulates search parameters for BugTask.search()
370
371
372=== modified file 'lib/lp/bugs/model/bugtask.py'
373--- lib/lp/bugs/model/bugtask.py 2011-07-22 04:17:05 +0000
374+++ lib/lp/bugs/model/bugtask.py 2011-07-22 04:38:51 +0000
375@@ -57,7 +57,6 @@
376 from zope.component import getUtility
377 from zope.event import notify
378 from zope.interface import (
379- alsoProvides,
380 implements,
381 providedBy,
382 )
383@@ -119,12 +118,8 @@
384 IBugTask,
385 IBugTaskDelta,
386 IBugTaskSet,
387- IDistroBugTask,
388- IDistroSeriesBugTask,
389 IllegalRelatedBugTasksParams,
390 IllegalTarget,
391- IProductSeriesBugTask,
392- IUpstreamBugTask,
393 RESOLVED_BUGTASK_STATUSES,
394 UNRESOLVED_BUGTASK_STATUSES,
395 UserCannotEditBugTaskAssignee,
396@@ -528,9 +523,6 @@
397 @property
398 def target(self):
399 """See `IBugTask`."""
400- # We explicitly reference attributes here (rather than, say,
401- # IDistroBugTask.providedBy(self)), because we can't assume this
402- # task has yet been marked with the correct interface.
403 return determine_target(
404 self.product, self.productseries, self.distribution,
405 self.distroseries, self.sourcepackagename)
406@@ -670,7 +662,7 @@
407 def getConjoinedMaster(self, bugtasks, bugtasks_by_package=None):
408 """See `IBugTask`."""
409 conjoined_master = None
410- if IDistroBugTask.providedBy(self):
411+ if self.distribution:
412 if bugtasks_by_package is None:
413 bugtasks_by_package = (
414 self.bug.getBugTasksByPackageName(bugtasks))
415@@ -688,7 +680,7 @@
416 if bugtask.distroseries == current_series:
417 conjoined_master = bugtask
418 break
419- elif IUpstreamBugTask.providedBy(self):
420+ elif self.product:
421 assert self.product.development_focusID is not None, (
422 'A product should always have a development series.')
423 devel_focusID = self.product.development_focusID
424@@ -714,7 +706,7 @@
425 def conjoined_slave(self):
426 """See `IBugTask`."""
427 conjoined_slave = None
428- if IDistroSeriesBugTask.providedBy(self):
429+ if self.distroseries:
430 distribution = self.distroseries.distribution
431 if self.distroseries != distribution.currentseries:
432 # Only current series tasks are conjoined.
433@@ -724,7 +716,7 @@
434 bugtask.sourcepackagename == self.sourcepackagename):
435 conjoined_slave = bugtask
436 break
437- elif IProductSeriesBugTask.providedBy(self):
438+ elif self.productseries:
439 product = self.productseries.product
440 if self.productseries != product.development_focus:
441 # Only development focus tasks are conjoined.
442@@ -755,27 +747,6 @@
443 # setter methods directly.
444 setattr(self, synched_attr, PassthroughValue(slave_attr_value))
445
446- def _init(self, *args, **kw):
447- """Marks the task when it's created or fetched from the database."""
448- SQLBase._init(self, *args, **kw)
449-
450- # We check both the foreign key column and the reference so we
451- # can detect unflushed references. The reference check will
452- # only be made if the FK is None, so no additional queries
453- # will be executed.
454- if self.productID is not None or self.product is not None:
455- alsoProvides(self, IUpstreamBugTask)
456- elif (self.productseriesID is not None or
457- self.productseries is not None):
458- alsoProvides(self, IProductSeriesBugTask)
459- elif self.distroseriesID is not None or self.distroseries is not None:
460- alsoProvides(self, IDistroSeriesBugTask)
461- elif self.distributionID is not None or self.distribution is not None:
462- # If nothing else, this is a distro task.
463- alsoProvides(self, IDistroBugTask)
464- else:
465- raise AssertionError("Task %d is floating." % self.id)
466-
467 @property
468 def target_uses_malone(self):
469 """See `IBugTask`"""
470@@ -1097,7 +1068,7 @@
471 # current target, or reset it to None
472 self.milestone = None
473
474- if IUpstreamBugTask.providedBy(self):
475+ if self.product:
476 if IProduct.providedBy(target):
477 self.product = target
478 else:
479@@ -1177,12 +1148,12 @@
480 else:
481 component_name = component.name
482
483- if IUpstreamBugTask.providedBy(self):
484+ if self.product:
485 header_value = 'product=%s;' % self.target.name
486- elif IProductSeriesBugTask.providedBy(self):
487+ elif self.productseries:
488 header_value = 'product=%s; productseries=%s;' % (
489 self.productseries.product.name, self.productseries.name)
490- elif IDistroBugTask.providedBy(self):
491+ elif self.distribution:
492 header_value = ((
493 'distribution=%(distroname)s; '
494 'sourcepackage=%(sourcepackagename)s; '
495@@ -1190,7 +1161,7 @@
496 {'distroname': self.distribution.name,
497 'sourcepackagename': sourcepackagename_value,
498 'componentname': component_name})
499- elif IDistroSeriesBugTask.providedBy(self):
500+ elif self.distroseries:
501 header_value = ((
502 'distribution=%(distroname)s; '
503 'distroseries=%(distroseriesname)s; '
504@@ -1219,25 +1190,6 @@
505
506 def getDelta(self, old_task):
507 """See `IBugTask`."""
508- valid_interfaces = [
509- IUpstreamBugTask,
510- IProductSeriesBugTask,
511- IDistroBugTask,
512- IDistroSeriesBugTask,
513- ]
514-
515- # This tries to find a matching pair of bug tasks, i.e. where
516- # both provide IUpstreamBugTask, or both IDistroBugTask.
517- # Failing that, it drops off the bottom of the loop and raises
518- # the TypeError.
519- for interface in valid_interfaces:
520- if interface.providedBy(self) and interface.providedBy(old_task):
521- break
522- else:
523- raise TypeError(
524- "Can't calculate delta on bug tasks of incompatible types: "
525- "[%s, %s]." % (repr(old_task), repr(self)))
526-
527 # calculate the differences in the fields that both types of tasks
528 # have in common
529 changes = {}
530@@ -1260,14 +1212,7 @@
531 """Can the user edit this tasks's pillar?"""
532 if user is None:
533 return False
534- if IUpstreamBugTask.providedBy(self):
535- pillar = self.product
536- elif IProductSeriesBugTask.providedBy(self):
537- pillar = self.productseries.product
538- elif IDistroBugTask.providedBy(self):
539- pillar = self.distribution
540- else:
541- pillar = self.distroseries.distribution
542+ pillar = self.pillar
543 return ((pillar.bug_supervisor is not None and
544 user.inTeam(pillar.bug_supervisor)) or
545 pillar.userCanEdit(user))
546
547=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
548--- lib/lp/bugs/model/tests/test_bugtask.py 2011-07-21 06:44:22 +0000
549+++ lib/lp/bugs/model/tests/test_bugtask.py 2011-07-22 04:38:51 +0000
550@@ -81,18 +81,6 @@
551 bug_task = self.factory.makeBugTask()
552 self.assertEqual(bug_task.getDelta(bug_task), None)
553
554- def test_get_mismatched_delta(self):
555- # getDelta() should raise TypeError when different types of
556- # bug tasks are passed in.
557- product = self.factory.makeProduct()
558- product_bug_task = self.factory.makeBugTask(target=product)
559- distro_source_package = self.factory.makeDistributionSourcePackage()
560- distro_source_package_bug_task = self.factory.makeBugTask(
561- target=distro_source_package)
562- self.assertRaises(
563- TypeError, product_bug_task.getDelta,
564- distro_source_package_bug_task)
565-
566 def check_delta(self, bug_task_before, bug_task_after, **expected_delta):
567 # Get a delta between one bug task and another, then compare
568 # the contents of the delta with expected_delta (a dict, or
569
570=== modified file 'lib/lp/bugs/tests/test_bugnotification.py'
571--- lib/lp/bugs/tests/test_bugnotification.py 2011-05-23 09:13:32 +0000
572+++ lib/lp/bugs/tests/test_bugnotification.py 2011-07-22 04:38:51 +0000
573@@ -29,7 +29,7 @@
574 from lp.answers.tests.test_question_notifications import pop_questionemailjobs
575 from lp.bugs.interfaces.bugtask import (
576 BugTaskStatus,
577- IUpstreamBugTask,
578+ IBugTask,
579 )
580 from lp.bugs.model.bugnotification import (
581 BugNotification,
582@@ -134,8 +134,7 @@
583 # Ensure that notifications are sent to subscribers of a
584 # question linked to the expired bug.
585 bugtask = self.bug.default_bugtask
586- bugtask_before_modification = Snapshot(
587- bugtask, providing=IUpstreamBugTask)
588+ bugtask_before_modification = Snapshot(bugtask, providing=IBugTask)
589 bugtask.transitionToStatus(BugTaskStatus.EXPIRED, self.product.owner)
590 bug_modified = ObjectModifiedEvent(
591 bugtask, bugtask_before_modification, ["status"])