1140
1140
def validateTransitionToTarget(self, target):
1141
1141
"""See `IBugTask`."""
1142
from lp.registry.model.distroseries import DistroSeries
1142
1144
# Check if any series are involved. You can't retarget series
1143
1145
# tasks. Except for DistroSeries/SourcePackage tasks, which can
1144
1146
# only be retargetted to another SourcePackage in the same
1161
1163
if len(series) != 1:
1162
1164
raise IllegalTarget(
1163
"Distribution series tasks may only be retargetted "
1165
"Distribution series tasks may only be retargeted "
1164
1166
"to a package within the same series.")
1167
# Because of the mildly insane way that DistroSeries nominations
1168
# work (they affect all Distributions and
1169
# DistributionSourcePackages), we can't sensibly allow
1170
# pillar changes to/from distributions with series tasks on this
1171
# bug. That would require us to create or delete tasks.
1172
# Changing just the sourcepackagename is OK, though, as a
1173
# validator on sourcepackagename will change all related tasks.
1174
elif interfaces.intersection(
1175
(IDistribution, IDistributionSourcePackage)):
1176
# Work out the involved distros (will include None if there
1177
# are product tasks).
1179
for potential_target in (target, self.target):
1180
if IDistribution.providedBy(potential_target):
1181
distros.add(potential_target)
1182
elif IDistributionSourcePackage.providedBy(potential_target):
1183
distros.add(potential_target.distribution)
1186
if len(distros) > 1:
1187
# Multiple distros involved. Check that none of their
1188
# series have tasks on this bug.
1189
if not Store.of(self).find(
1191
BugTask.bugID == self.bugID,
1192
BugTask.distroseriesID == DistroSeries.id,
1193
DistroSeries.distributionID.is_in(
1194
distro.id for distro in distros if distro),
1196
raise IllegalTarget(
1197
"Distribution tasks with corresponding series "
1198
"tasks may only be retargeted to a different "
1166
1201
validate_target(self.bug, target)