175
176
DistroSeriesDifferenceStatus,
176
177
DistroSeriesDifferenceType,
178
from lp.registry.interfaces.distribution import IDistributionSet
179
from lp.registry.interfaces.distribution import (
179
183
from lp.registry.interfaces.distributionmirror import (
1707
def makeBugTask(self, bug=None, target=None, owner=None, publish=True):
1712
def makeBugTask(self, bug=None, target=None, owner=None, publish=True,
1708
1714
"""Create and return a bug task.
1710
1716
If the bug is already targeted to the given target, the existing
1711
1717
bug task is returned.
1719
Private (and soon all) bugs cannot affect multiple projects
1720
so we ensure that if a bug has not been specified and one is
1721
created, it is for the same pillar as that of the specified target.
1713
1723
:param bug: The `IBug` the bug tasks should be part of. If None,
1714
1724
one will be created.
1715
1725
:param target: The `IBugTarget`, to which the bug will be
1727
:param private: If a bug is not specified, the privacy state to use
1728
when creating the bug for the bug task..
1719
bug = self.makeBug()
1731
# Find and return the existing target if one exists.
1732
if bug is not None and target is not None:
1733
existing_bugtask = bug.getBugTask(target)
1734
if existing_bugtask is not None:
1735
return existing_bugtask
1737
# If we are adding a task to an existing bug, and no target is
1738
# is specified, we use the same pillar as already exists to ensure
1739
# that we don't end up with a bug affecting multiple projects.
1720
1740
if target is None:
1721
target = self.makeProduct()
1722
existing_bugtask = bug.getBugTask(target)
1723
if existing_bugtask is not None:
1724
return existing_bugtask
1727
owner = self.makePerson()
1741
default_bugtask = bug and removeSecurityProxy(bug.default_bugtask)
1742
if default_bugtask is not None:
1743
existing_pillar = default_bugtask.pillar
1744
if IProduct.providedBy(existing_pillar):
1745
target = self.makeProductSeries(product=existing_pillar)
1746
elif IDistribution.providedBy(existing_pillar):
1747
target = self.makeDistroSeries(
1748
distribution=existing_pillar)
1750
target = self.makeProduct()
1729
1752
prerequisite_target = None
1730
1753
if IProductSeries.providedBy(target):
1746
1769
distroseries=target.distribution.currentseries,
1747
1770
sourcepackagename=target.sourcepackagename)
1748
1771
if prerequisite_target is not None:
1749
prerequisite = bug.getBugTask(prerequisite_target)
1772
prerequisite = bug and bug.getBugTask(prerequisite_target)
1750
1773
if prerequisite is None:
1751
self.makeBugTask(bug, prerequisite_target, publish=publish)
1774
prerequisite = self.makeBugTask(
1775
bug, prerequisite_target, publish=publish)
1776
bug = prerequisite.bug
1778
# Private (and soon all) bugs cannot affect multiple projects
1779
# so we ensure that if a bug has not been specified and one is
1780
# created, it is for the same pillar as that of the specified target.
1781
result_bug_task = None
1782
if bug is None and private:
1783
product = distribution = sourcepackagename = None
1784
pillar = target.pillar
1785
if IProduct.providedBy(pillar):
1787
elif IDistribution.providedBy(pillar):
1788
distribution = pillar
1789
if (IDistributionSourcePackage.providedBy(target)
1790
or ISourcePackage.providedBy(target)):
1791
sourcepackagename = target.sourcepackagename
1793
private=private, product=product, distribution=distribution,
1794
sourcepackagename=sourcepackagename)
1795
if not ISeriesBugTarget.providedBy(target):
1796
result_bug_task = bug.default_bugtask
1797
# We keep the existing behaviour for public bugs because
1798
# test_bugtask_search breaks spectacularly otherwise. Almost all other
1801
bug = self.makeBug()
1803
if result_bug_task is not None:
1804
return result_bug_task
1806
owner = self.makePerson()
1753
1807
return removeSecurityProxy(bug).addTask(owner, target)
1755
1809
def makeBugNomination(self, bug=None, target=None):