launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04368
[Merge] lp:~wgrant/launchpad/transitionToTarget-series-sourcepackage into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/transitionToTarget-series-sourcepackage into lp:launchpad with lp:~wgrant/launchpad/sensible-validate_target as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/transitionToTarget-series-sourcepackage/+merge/69191
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.
--
https://code.launchpad.net/~wgrant/launchpad/transitionToTarget-series-sourcepackage/+merge/69191
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/transitionToTarget-series-sourcepackage into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py 2011-07-26 01:31:36 +0000
+++ lib/lp/bugs/model/bugtask.py 2011-07-26 01:31:37 +0000
@@ -1157,20 +1157,28 @@
self.milestone = None
# Check if any series are involved. You can't retarget series
- # tasks. Except for SourcePackage tasks, which can only be
- # retargetted to another SourcePackage in the same DistroSeries.
+ # tasks. Except for DistroSeries/SourcePackage tasks, which can
+ # only be retargetted to another SourcePackage in the same
+ # DistroSeries, or the DistroSeries.
interfaces = set(providedBy(target))
interfaces.update(providedBy(self.target))
- if interfaces.intersection((IProductSeries, IDistroSeries)):
+ if IProductSeries in interfaces:
raise IllegalTarget(
"Series tasks may only be created by approving nominations.")
- elif ISourcePackage in interfaces:
- if (not ISourcePackage.providedBy(target) or
- not ISourcePackage.providedBy(self.target) or
- target.distroseries != self.target.distroseries):
+ elif interfaces.intersection((IDistroSeries, ISourcePackage)):
+ series = set()
+ for potential_target in (target, self.target):
+ if IDistroSeries.providedBy(potential_target):
+ series.add(potential_target)
+ elif ISourcePackage.providedBy(potential_target):
+ series.add(potential_target.distroseries)
+ else:
+ series = set()
+ break
+ if len(series) != 1:
raise IllegalTarget(
- "Series source package tasks may only be retargetted "
- "to another source package in the same series.")
+ "Distribution series tasks may only be retargetted "
+ "to a package within the same series.")
# Inhibit validate_target_attribute, as we can't set them all
# atomically, but we know the final result is correct.
=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
--- lib/lp/bugs/model/tests/test_bugtask.py 2011-07-26 01:31:36 +0000
+++ lib/lp/bugs/model/tests/test_bugtask.py 2011-07-26 01:31:37 +0000
@@ -1713,6 +1713,10 @@
sp2 = self.factory.makeSourcePackage(distroseries=sp1.distroseries)
self.assertTransitionWorks(sp1, sp2)
+ def test_sourcepackage_to_same_series_works(self):
+ sp = self.factory.makeSourcePackage()
+ self.assertTransitionWorks(sp, sp.distroseries)
+
def test_different_distros_works(self):
self.assertTransitionWorks(
self.factory.makeDistributionSourcePackage(),