Merge ~cjwatson/launchpad:initialize-distroseries-proposed into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: e9da2379819721daeeec92deadb3203be17d84fd
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:initialize-distroseries-proposed
Merge into: launchpad:master
Diff against target: 237 lines (+106/-43)
2 files modified
lib/lp/soyuz/scripts/initialize_distroseries.py (+43/-37)
lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py (+63/-6)
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+374134@code.launchpad.net

Commit message

Fix source/target pocket handling in InitializeDistroSeries

Copy pockets other than RELEASE when using the cloner as well as when
using the copier; and copy packages from PROPOSED to PROPOSED rather
than to RELEASE, since (unlike UPDATES and SECURITY) the PROPOSED pocket
is modifiable in unreleased series.

LP: #1824966

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)
Revision history for this message
Adam Conrad (adconrad) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/soyuz/scripts/initialize_distroseries.py b/lib/lp/soyuz/scripts/initialize_distroseries.py
2index 6a9753e..d266a84 100644
3--- a/lib/lp/soyuz/scripts/initialize_distroseries.py
4+++ b/lib/lp/soyuz/scripts/initialize_distroseries.py
5@@ -9,6 +9,7 @@ __all__ = [
6 'InitializeDistroSeries',
7 ]
8
9+from collections import OrderedDict
10 from operator import methodcaller
11
12 import transaction
13@@ -54,13 +55,15 @@ class InitializationError(Exception):
14 """Raised when there is an exception during the initialization process."""
15
16
17-# Pockets to consider when initializing the derived series from its parent(s).
18-INIT_POCKETS = [
19- PackagePublishingPocket.RELEASE,
20- PackagePublishingPocket.SECURITY,
21- PackagePublishingPocket.UPDATES,
22- PackagePublishingPocket.PROPOSED,
23- ]
24+# Pockets to consider when initializing the derived series from its
25+# parent(s), mapped to the pockets that they should be cloned/copied to. We
26+# need this because some pockets are unmodifiable in unreleased series.
27+INIT_POCKETS = OrderedDict([
28+ (PackagePublishingPocket.RELEASE, PackagePublishingPocket.RELEASE),
29+ (PackagePublishingPocket.SECURITY, PackagePublishingPocket.RELEASE),
30+ (PackagePublishingPocket.UPDATES, PackagePublishingPocket.RELEASE),
31+ (PackagePublishingPocket.PROPOSED, PackagePublishingPocket.PROPOSED),
32+ ])
33
34
35 class InitializeDistroSeries:
36@@ -233,7 +236,7 @@ class InitializeDistroSeries:
37
38 arch_tags = self.arches if len(self.arches) != 0 else None
39 pending_builds = parent.getBuildRecords(
40- BuildStatus.NEEDSBUILD, pocket=INIT_POCKETS,
41+ BuildStatus.NEEDSBUILD, pocket=list(INIT_POCKETS),
42 arch_tag=arch_tags, name=spns)
43
44 if not pending_builds.is_empty():
45@@ -263,7 +266,7 @@ class InitializeDistroSeries:
46 # all sources.
47
48 items = getUtility(IPackageUploadSet).getBuildsForSources(
49- parent, statuses, INIT_POCKETS, spns)
50+ parent, statuses, list(INIT_POCKETS), spns)
51 if not items.is_empty():
52 raise InitializationError(
53 "The parent series has sources waiting in its upload "
54@@ -548,40 +551,43 @@ class InitializeDistroSeries:
55 assert target_archive is not None, (
56 "Target archive doesn't exist?")
57 if self._use_cloner(target_archive, archive):
58- origin = PackageLocation(
59- archive, parent.distribution, parent,
60- PackagePublishingPocket.RELEASE)
61- destination = PackageLocation(
62- target_archive, self.distroseries.distribution,
63- self.distroseries, PackagePublishingPocket.RELEASE)
64- processors = None
65- if self.rebuild:
66- processors = [
67- das[1].processor for das in distroarchseries_list]
68- distroarchseries_list = ()
69- getUtility(IPackageCloner).clonePackages(
70- origin, destination, distroarchseries_list,
71- processors, spns)
72+ for source_pocket, target_pocket in INIT_POCKETS.items():
73+ origin = PackageLocation(
74+ archive, parent.distribution, parent,
75+ source_pocket)
76+ destination = PackageLocation(
77+ target_archive, self.distroseries.distribution,
78+ self.distroseries, target_pocket)
79+ processors = None
80+ if self.rebuild:
81+ processors = [
82+ das[1].processor
83+ for das in distroarchseries_list]
84+ distroarchseries_list = ()
85+ getUtility(IPackageCloner).clonePackages(
86+ origin, destination, distroarchseries_list,
87+ processors, spns)
88 else:
89- # There is only one available pocket in an unreleased
90- # series.
91- target_pocket = PackagePublishingPocket.RELEASE
92- sources = archive.getPublishedSources(
93- distroseries=parent, pocket=INIT_POCKETS,
94- status=(PackagePublishingStatus.PENDING,
95- PackagePublishingStatus.PUBLISHED),
96- name=spns)
97 # XXX: rvb 2011-06-23 bug=801112: do_copy is atomic (all
98 # or none of the sources will be copied). This might
99 # lead to a partially initialised series if there is a
100 # single conflict in the destination series.
101+ sources_published = []
102 try:
103- sources_published = do_copy(
104- sources, target_archive, self.distroseries,
105- target_pocket, include_binaries=not self.rebuild,
106- check_permissions=False, strict_binaries=False,
107- close_bugs=False, create_dsd_job=False,
108- person=None)
109+ for source_pocket, target_pocket in (
110+ INIT_POCKETS.items()):
111+ sources = archive.getPublishedSources(
112+ distroseries=parent, pocket=source_pocket,
113+ status=(PackagePublishingStatus.PENDING,
114+ PackagePublishingStatus.PUBLISHED),
115+ name=spns)
116+ sources_published.extend(do_copy(
117+ sources, target_archive, self.distroseries,
118+ target_pocket,
119+ include_binaries=not self.rebuild,
120+ check_permissions=False, strict_binaries=False,
121+ close_bugs=False, create_dsd_job=False,
122+ person=None))
123 if self.rebuild:
124 rebuilds = []
125 for pubrec in sources_published:
126diff --git a/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py b/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py
127index bd2cf15..25d2cb3 100644
128--- a/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py
129+++ b/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py
130@@ -374,22 +374,74 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
131 # No exception should be raised.
132 ids.check()
133
134- def test_success_with_updates_packages(self):
135- # Initialization copies all the package from the UPDATES pocket.
136+ def test_success_with_updates_packages_cloner(self):
137+ # Initialization using the cloner copies all the packages from the
138+ # UPDATES pocket.
139+ self.parent, self.parent_das = self.setupParent(
140+ pocket=PackagePublishingPocket.UPDATES)
141+ self.factory.makeSourcePackagePublishingHistory(
142+ distroseries=self.parent)
143+ child = self._fullInitialize(
144+ [self.parent], previous_series=self.parent,
145+ distribution=self.parent.distribution)
146+ self.assertDistroSeriesInitializedCorrectly(
147+ child, self.parent, self.parent_das)
148+
149+ def test_success_with_updates_packages_copier(self):
150+ # Initialization using the copier copies all the packages from the
151+ # UPDATES pocket.
152 self.parent, self.parent_das = self.setupParent(
153 pocket=PackagePublishingPocket.UPDATES)
154 child = self._fullInitialize([self.parent])
155 self.assertDistroSeriesInitializedCorrectly(
156 child, self.parent, self.parent_das)
157
158- def test_success_with_security_packages(self):
159- # Initialization copies all the package from the SECURITY pocket.
160+ def test_success_with_security_packages_cloner(self):
161+ # Initialization using the cloner copies all the packages from the
162+ # SECURITY pocket.
163+ self.parent, self.parent_das = self.setupParent(
164+ pocket=PackagePublishingPocket.SECURITY)
165+ self.factory.makeSourcePackagePublishingHistory(
166+ distroseries=self.parent)
167+ child = self._fullInitialize(
168+ [self.parent], previous_series=self.parent,
169+ distribution=self.parent.distribution)
170+ self.assertDistroSeriesInitializedCorrectly(
171+ child, self.parent, self.parent_das)
172+
173+ def test_success_with_security_packages_copier(self):
174+ # Initialization using the copier copies all the packages from the
175+ # SECURITY pocket.
176 self.parent, self.parent_das = self.setupParent(
177 pocket=PackagePublishingPocket.SECURITY)
178 child = self._fullInitialize([self.parent])
179 self.assertDistroSeriesInitializedCorrectly(
180 child, self.parent, self.parent_das)
181
182+ def test_success_with_proposed_packages_cloner(self):
183+ # Initialization using the cloner copies all the packages from the
184+ # PROPOSED pocket.
185+ self.parent, self.parent_das = self.setupParent(
186+ pocket=PackagePublishingPocket.PROPOSED)
187+ self.factory.makeSourcePackagePublishingHistory(
188+ distroseries=self.parent)
189+ child = self._fullInitialize(
190+ [self.parent], previous_series=self.parent,
191+ distribution=self.parent.distribution)
192+ self.assertDistroSeriesInitializedCorrectly(
193+ child, self.parent, self.parent_das,
194+ child_pocket=PackagePublishingPocket.PROPOSED)
195+
196+ def test_success_with_proposed_packages_copier(self):
197+ # Initialization using the copier copies all the packages from the
198+ # PROPOSED pocket.
199+ self.parent, self.parent_das = self.setupParent(
200+ pocket=PackagePublishingPocket.PROPOSED)
201+ child = self._fullInitialize([self.parent])
202+ self.assertDistroSeriesInitializedCorrectly(
203+ child, self.parent, self.parent_das,
204+ child_pocket=PackagePublishingPocket.PROPOSED)
205+
206 def test_do_not_copy_superseded_sources(self):
207 # Make sure we don't copy superseded sources from the parent,
208 # we only want (pending, published).
209@@ -578,8 +630,9 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
210 "queues that match your selection."),
211 ids.check)
212
213- def assertDistroSeriesInitializedCorrectly(self, child, parent,
214- parent_das):
215+ def assertDistroSeriesInitializedCorrectly(
216+ self, child, parent, parent_das,
217+ child_pocket=PackagePublishingPocket.RELEASE):
218 # Check that 'udev' has been copied correctly.
219 parent_udev_pubs = parent.main_archive.getPublishedSources(
220 u'udev', distroseries=parent)
221@@ -587,12 +640,16 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
222 u'udev', distroseries=child)
223 self.assertEqual(
224 parent_udev_pubs.count(), child_udev_pubs.count())
225+ self.assertEqual(
226+ {child_pocket}, set(pub.pocket for pub in child_udev_pubs))
227 parent_arch_udev_pubs = parent.main_archive.getAllPublishedBinaries(
228 distroarchseries=parent[parent_das.architecturetag], name=u'udev')
229 child_arch_udev_pubs = child.main_archive.getAllPublishedBinaries(
230 distroarchseries=child[parent_das.architecturetag], name=u'udev')
231 self.assertEqual(
232 parent_arch_udev_pubs.count(), child_arch_udev_pubs.count())
233+ self.assertEqual(
234+ {child_pocket}, set(pub.pocket for pub in child_arch_udev_pubs))
235 # And the binary package, and linked source package look fine too.
236 udev_bin = child_arch_udev_pubs[0].binarypackagerelease
237 self.assertEqual(udev_bin.title, u'udev-0.1-1')

Subscribers

People subscribed via source and target branches

to status/vote changes: