Merge lp:~wgrant/launchpad/transitionToTarget-series-sourcepackage into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 13531
Proposed branch: lp:~wgrant/launchpad/transitionToTarget-series-sourcepackage
Merge into: lp:launchpad
Prerequisite: lp:~wgrant/launchpad/sensible-validate_target
Diff against target: 56 lines (+21/-9)
2 files modified
lib/lp/bugs/model/bugtask.py (+17/-9)
lib/lp/bugs/model/tests/test_bugtask.py (+4/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/transitionToTarget-series-sourcepackage
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+69191@code.launchpad.net

Commit message

Fix BugTask.transitionToTarget to permit DistroSeries<->SourcePackage transitions, where the series matches.

Description of the change

Quick change to allow BugTask.transitionToTarget between DistroSeries and SourcePackage tasks, as long as the series matches. Needed to allow clearing a SourcePackage task's SourcePackageName in the UI, which is presently permitted.

These rules suck, but this is refactoring rather than redefining.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) :
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/model/bugtask.py'
2--- lib/lp/bugs/model/bugtask.py 2011-07-26 01:31:36 +0000
3+++ lib/lp/bugs/model/bugtask.py 2011-07-26 01:31:37 +0000
4@@ -1157,20 +1157,28 @@
5 self.milestone = None
6
7 # Check if any series are involved. You can't retarget series
8- # tasks. Except for SourcePackage tasks, which can only be
9- # retargetted to another SourcePackage in the same DistroSeries.
10+ # tasks. Except for DistroSeries/SourcePackage tasks, which can
11+ # only be retargetted to another SourcePackage in the same
12+ # DistroSeries, or the DistroSeries.
13 interfaces = set(providedBy(target))
14 interfaces.update(providedBy(self.target))
15- if interfaces.intersection((IProductSeries, IDistroSeries)):
16+ if IProductSeries in interfaces:
17 raise IllegalTarget(
18 "Series tasks may only be created by approving nominations.")
19- elif ISourcePackage in interfaces:
20- if (not ISourcePackage.providedBy(target) or
21- not ISourcePackage.providedBy(self.target) or
22- target.distroseries != self.target.distroseries):
23+ elif interfaces.intersection((IDistroSeries, ISourcePackage)):
24+ series = set()
25+ for potential_target in (target, self.target):
26+ if IDistroSeries.providedBy(potential_target):
27+ series.add(potential_target)
28+ elif ISourcePackage.providedBy(potential_target):
29+ series.add(potential_target.distroseries)
30+ else:
31+ series = set()
32+ break
33+ if len(series) != 1:
34 raise IllegalTarget(
35- "Series source package tasks may only be retargetted "
36- "to another source package in the same series.")
37+ "Distribution series tasks may only be retargetted "
38+ "to a package within the same series.")
39
40 # Inhibit validate_target_attribute, as we can't set them all
41 # atomically, but we know the final result is correct.
42
43=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
44--- lib/lp/bugs/model/tests/test_bugtask.py 2011-07-26 01:31:36 +0000
45+++ lib/lp/bugs/model/tests/test_bugtask.py 2011-07-26 01:31:37 +0000
46@@ -1713,6 +1713,10 @@
47 sp2 = self.factory.makeSourcePackage(distroseries=sp1.distroseries)
48 self.assertTransitionWorks(sp1, sp2)
49
50+ def test_sourcepackage_to_same_series_works(self):
51+ sp = self.factory.makeSourcePackage()
52+ self.assertTransitionWorks(sp, sp.distroseries)
53+
54 def test_different_distros_works(self):
55 self.assertTransitionWorks(
56 self.factory.makeDistributionSourcePackage(),