Merge lp:~michael.nelson/launchpad/475808-unembargoing-oops into lp:launchpad/db-devel
- 475808-unembargoing-oops
- Merge into db-devel
Proposed by
Michael Nelson
Status: | Merged |
---|---|
Approved by: | Aaron Bentley |
Approved revision: | not available |
Merged at revision: | not available |
Proposed branch: | lp:~michael.nelson/launchpad/475808-unembargoing-oops |
Merge into: | lp:launchpad/db-devel |
Diff against target: |
405 lines (+208/-63) 4 files modified
lib/lp/soyuz/interfaces/publishing.py (+28/-0) lib/lp/soyuz/model/publishing.py (+29/-22) lib/lp/soyuz/model/queue.py (+41/-6) lib/lp/soyuz/scripts/tests/test_copypackage.py (+110/-35) |
To merge this branch: | bzr merge lp:~michael.nelson/launchpad/475808-unembargoing-oops |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Данило Шеган (community) | release-critical | Approve | |
Aaron Bentley (community) | Approve | ||
Review via email: mp+16141@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote : | # |
Revision history for this message
Данило Шеган (danilo) : | # |
review:
Approve
(release-critical)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/soyuz/interfaces/publishing.py' | |||
2 | --- lib/lp/soyuz/interfaces/publishing.py 2009-12-12 03:25:27 +0000 | |||
3 | +++ lib/lp/soyuz/interfaces/publishing.py 2009-12-21 09:19:13 +0000 | |||
4 | @@ -1139,6 +1139,34 @@ | |||
5 | 1139 | the source_package_pub, allowing the use of the cached results. | 1139 | the source_package_pub, allowing the use of the cached results. |
6 | 1140 | """ | 1140 | """ |
7 | 1141 | 1141 | ||
8 | 1142 | def getNearestAncestor( | ||
9 | 1143 | package_name, archive, distroseries, pocket=None, status=None, | ||
10 | 1144 | binary=False): | ||
11 | 1145 | """Return the ancestor of the given parkage in a particular archive. | ||
12 | 1146 | |||
13 | 1147 | :param package_name: The package name for which we are checking for | ||
14 | 1148 | an ancestor. | ||
15 | 1149 | :type package_name: ``string`` | ||
16 | 1150 | :param archive: The archive in which we are looking for an ancestor. | ||
17 | 1151 | :type archive: `IArchive` | ||
18 | 1152 | :param distroseries: The particular series in which we are looking for | ||
19 | 1153 | an ancestor. | ||
20 | 1154 | :type distroseries: `IDistroSeries` | ||
21 | 1155 | :param pocket: An optional pocket to restrict the search. | ||
22 | 1156 | :type pocket: `PackagePublishingPocket`. | ||
23 | 1157 | :param status: An optional status defaulting to PUBLISHED if not | ||
24 | 1158 | provided. | ||
25 | 1159 | :type status: `PackagePublishingStatus` | ||
26 | 1160 | :param binary: An optional argument to look for a binary ancestor | ||
27 | 1161 | instead of the default source. | ||
28 | 1162 | :type binary: ``Boolean`` | ||
29 | 1163 | |||
30 | 1164 | :return: The most recent publishing history for the given | ||
31 | 1165 | arguments. | ||
32 | 1166 | :rtype: `ISourcePackagePublishingHistory` or | ||
33 | 1167 | `IBinaryPackagePublishingHistory` or None. | ||
34 | 1168 | """ | ||
35 | 1169 | |||
36 | 1142 | active_publishing_status = ( | 1170 | active_publishing_status = ( |
37 | 1143 | PackagePublishingStatus.PENDING, | 1171 | PackagePublishingStatus.PENDING, |
38 | 1144 | PackagePublishingStatus.PUBLISHED, | 1172 | PackagePublishingStatus.PUBLISHED, |
39 | 1145 | 1173 | ||
40 | === modified file 'lib/lp/soyuz/model/publishing.py' | |||
41 | --- lib/lp/soyuz/model/publishing.py 2009-12-14 13:49:03 +0000 | |||
42 | +++ lib/lp/soyuz/model/publishing.py 2009-12-21 09:19:13 +0000 | |||
43 | @@ -835,17 +835,10 @@ | |||
44 | 835 | archive = self.archive | 835 | archive = self.archive |
45 | 836 | if distroseries is None: | 836 | if distroseries is None: |
46 | 837 | distroseries = self.distroseries | 837 | distroseries = self.distroseries |
58 | 838 | if status is None: | 838 | |
59 | 839 | status = PackagePublishingStatus.PUBLISHED | 839 | return getUtility(IPublishingSet).getNearestAncestor( |
60 | 840 | 840 | self.source_package_name, archive, distroseries, pocket, | |
61 | 841 | ancestries = archive.getPublishedSources( | 841 | status) |
51 | 842 | name=self.source_package_name, exact_match=True, | ||
52 | 843 | status=status, distroseries=distroseries, pocket=pocket) | ||
53 | 844 | |||
54 | 845 | if ancestries.count() > 0: | ||
55 | 846 | return ancestries[0] | ||
56 | 847 | |||
57 | 848 | return None | ||
62 | 849 | 842 | ||
63 | 850 | def overrideFromAncestry(self): | 843 | def overrideFromAncestry(self): |
64 | 851 | """See `ISourcePackagePublishingHistory`.""" | 844 | """See `ISourcePackagePublishingHistory`.""" |
65 | @@ -1101,17 +1094,10 @@ | |||
66 | 1101 | archive = self.archive | 1094 | archive = self.archive |
67 | 1102 | if distroseries is None: | 1095 | if distroseries is None: |
68 | 1103 | distroseries = self.distroarchseries.distroseries | 1096 | distroseries = self.distroarchseries.distroseries |
80 | 1104 | if status is None: | 1097 | |
81 | 1105 | status = PackagePublishingStatus.PUBLISHED | 1098 | return getUtility(IPublishingSet).getNearestAncestor( |
82 | 1106 | 1099 | self.binary_package_name, archive, distroseries, pocket, | |
83 | 1107 | ancestries = archive.getAllPublishedBinaries( | 1100 | status, binary=True) |
73 | 1108 | name=self.binary_package_name, exact_match=True, pocket=pocket, | ||
74 | 1109 | status=status, distroarchseries=distroseries.architectures) | ||
75 | 1110 | |||
76 | 1111 | if ancestries.count() > 0: | ||
77 | 1112 | return ancestries[0] | ||
78 | 1113 | |||
79 | 1114 | return None | ||
84 | 1115 | 1101 | ||
85 | 1116 | def overrideFromAncestry(self): | 1102 | def overrideFromAncestry(self): |
86 | 1117 | """See `IBinaryPackagePublishingHistory`.""" | 1103 | """See `IBinaryPackagePublishingHistory`.""" |
87 | @@ -1699,3 +1685,24 @@ | |||
88 | 1699 | store.execute(query) | 1685 | store.execute(query) |
89 | 1700 | 1686 | ||
90 | 1701 | return sources + binary_packages | 1687 | return sources + binary_packages |
91 | 1688 | |||
92 | 1689 | def getNearestAncestor( | ||
93 | 1690 | self, package_name, archive, distroseries, pocket=None, | ||
94 | 1691 | status=None, binary=False): | ||
95 | 1692 | """See `IPublishingSet`.""" | ||
96 | 1693 | if status is None: | ||
97 | 1694 | status = PackagePublishingStatus.PUBLISHED | ||
98 | 1695 | |||
99 | 1696 | if binary: | ||
100 | 1697 | ancestries = archive.getAllPublishedBinaries( | ||
101 | 1698 | name=package_name, exact_match=True, pocket=pocket, | ||
102 | 1699 | status=status, distroarchseries=distroseries.architectures) | ||
103 | 1700 | else: | ||
104 | 1701 | ancestries = archive.getPublishedSources( | ||
105 | 1702 | name=package_name, exact_match=True, pocket=pocket, | ||
106 | 1703 | status=status, distroseries=distroseries) | ||
107 | 1704 | |||
108 | 1705 | if ancestries.count() > 0: | ||
109 | 1706 | return ancestries[0] | ||
110 | 1707 | |||
111 | 1708 | return None | ||
112 | 1702 | 1709 | ||
113 | === modified file 'lib/lp/soyuz/model/queue.py' | |||
114 | --- lib/lp/soyuz/model/queue.py 2009-12-14 13:49:03 +0000 | |||
115 | +++ lib/lp/soyuz/model/queue.py 2009-12-21 09:19:13 +0000 | |||
116 | @@ -18,8 +18,8 @@ | |||
117 | 18 | import StringIO | 18 | import StringIO |
118 | 19 | import tempfile | 19 | import tempfile |
119 | 20 | 20 | ||
122 | 21 | from email.MIMEMultipart import MIMEMultipart | 21 | from email.mime.multipart import MIMEMultipart |
123 | 22 | from email.MIMEText import MIMEText | 22 | from email.mime.text import MIMEText |
124 | 23 | 23 | ||
125 | 24 | from storm.locals import Desc, In, Join | 24 | from storm.locals import Desc, In, Join |
126 | 25 | from storm.store import Store | 25 | from storm.store import Store |
127 | @@ -546,7 +546,8 @@ | |||
128 | 546 | # it's available. | 546 | # it's available. |
129 | 547 | changes_file = None | 547 | changes_file = None |
130 | 548 | if ISourcePackagePublishingHistory.providedBy(pub_record): | 548 | if ISourcePackagePublishingHistory.providedBy(pub_record): |
132 | 549 | changes_file = pub_record.sourcepackagerelease.package_upload.changesfile | 549 | release = pub_record.sourcepackagerelease |
133 | 550 | changes_file = release.package_upload.changesfile | ||
134 | 550 | 551 | ||
135 | 551 | for new_file in update_files_privacy(pub_record): | 552 | for new_file in update_files_privacy(pub_record): |
136 | 552 | debug(logger, | 553 | debug(logger, |
137 | @@ -561,7 +562,8 @@ | |||
138 | 561 | debug( | 562 | debug( |
139 | 562 | logger, | 563 | logger, |
140 | 563 | "sending email to %s" % self.distroseries.changeslist) | 564 | "sending email to %s" % self.distroseries.changeslist) |
142 | 564 | changes_file_object = StringIO.StringIO(changes_file.read()) | 565 | changes_file_object = StringIO.StringIO( |
143 | 566 | changes_file.read()) | ||
144 | 565 | self.notify( | 567 | self.notify( |
145 | 566 | announce_list=self.distroseries.changeslist, | 568 | announce_list=self.distroseries.changeslist, |
146 | 567 | changes_file_object=changes_file_object, | 569 | changes_file_object=changes_file_object, |
147 | @@ -1303,9 +1305,28 @@ | |||
148 | 1303 | def checkComponentAndSection(self): | 1305 | def checkComponentAndSection(self): |
149 | 1304 | """See `IPackageUploadBuild`.""" | 1306 | """See `IPackageUploadBuild`.""" |
150 | 1305 | distroseries = self.packageupload.distroseries | 1307 | distroseries = self.packageupload.distroseries |
151 | 1308 | is_ppa = self.packageupload.archive.is_ppa | ||
152 | 1309 | is_delayed_copy = self.packageupload.is_delayed_copy | ||
153 | 1310 | |||
154 | 1306 | for binary in self.build.binarypackages: | 1311 | for binary in self.build.binarypackages: |
157 | 1307 | if (not self.packageupload.archive.is_ppa and | 1312 | component = binary.component |
158 | 1308 | binary.component not in distroseries.upload_components): | 1313 | |
159 | 1314 | if is_delayed_copy: | ||
160 | 1315 | # For a delayed copy the component will not yet have | ||
161 | 1316 | # had the chance to be overridden, so we'll check the value | ||
162 | 1317 | # that will be overridden by querying the ancestor in | ||
163 | 1318 | # the destination archive - if one is available. | ||
164 | 1319 | binary_name = binary.name | ||
165 | 1320 | ancestry = getUtility(IPublishingSet).getNearestAncestor( | ||
166 | 1321 | package_name=binary_name, | ||
167 | 1322 | archive=self.packageupload.archive, | ||
168 | 1323 | distroseries=self.packageupload.distroseries, binary=True) | ||
169 | 1324 | |||
170 | 1325 | if ancestry is not None: | ||
171 | 1326 | component = ancestry.component | ||
172 | 1327 | |||
173 | 1328 | if (not is_ppa and component not in | ||
174 | 1329 | distroseries.upload_components): | ||
175 | 1309 | # Only complain about non-PPA uploads. | 1330 | # Only complain about non-PPA uploads. |
176 | 1310 | raise QueueBuildAcceptError( | 1331 | raise QueueBuildAcceptError( |
177 | 1311 | 'Component "%s" is not allowed in %s' | 1332 | 'Component "%s" is not allowed in %s' |
178 | @@ -1491,6 +1512,20 @@ | |||
179 | 1491 | component = self.sourcepackagerelease.component | 1512 | component = self.sourcepackagerelease.component |
180 | 1492 | section = self.sourcepackagerelease.section | 1513 | section = self.sourcepackagerelease.section |
181 | 1493 | 1514 | ||
182 | 1515 | if self.packageupload.is_delayed_copy: | ||
183 | 1516 | # For a delayed copy the component will not yet have | ||
184 | 1517 | # had the chance to be overridden, so we'll check the value | ||
185 | 1518 | # that will be overridden by querying the ancestor in | ||
186 | 1519 | # the destination archive - if one is available. | ||
187 | 1520 | source_name = self.sourcepackagerelease.name | ||
188 | 1521 | ancestry = getUtility(IPublishingSet).getNearestAncestor( | ||
189 | 1522 | package_name=source_name, | ||
190 | 1523 | archive=self.packageupload.archive, | ||
191 | 1524 | distroseries=self.packageupload.distroseries) | ||
192 | 1525 | |||
193 | 1526 | if ancestry is not None: | ||
194 | 1527 | component = ancestry.component | ||
195 | 1528 | |||
196 | 1494 | if (not self.packageupload.archive.is_ppa and | 1529 | if (not self.packageupload.archive.is_ppa and |
197 | 1495 | component not in distroseries.upload_components): | 1530 | component not in distroseries.upload_components): |
198 | 1496 | # Only complain about non-PPA uploads. | 1531 | # Only complain about non-PPA uploads. |
199 | 1497 | 1532 | ||
200 | === modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py' | |||
201 | --- lib/lp/soyuz/scripts/tests/test_copypackage.py 2009-12-14 13:49:03 +0000 | |||
202 | +++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2009-12-21 09:19:13 +0000 | |||
203 | @@ -36,7 +36,8 @@ | |||
204 | 36 | IBinaryPackagePublishingHistory, ISourcePackagePublishingHistory, | 36 | IBinaryPackagePublishingHistory, ISourcePackagePublishingHistory, |
205 | 37 | PackagePublishingStatus, active_publishing_status) | 37 | PackagePublishingStatus, active_publishing_status) |
206 | 38 | from lp.soyuz.interfaces.queue import ( | 38 | from lp.soyuz.interfaces.queue import ( |
208 | 39 | PackageUploadCustomFormat, PackageUploadStatus) | 39 | PackageUploadCustomFormat, PackageUploadStatus, |
209 | 40 | QueueInconsistentStateError) | ||
210 | 40 | from lp.soyuz.interfaces.sourcepackageformat import ( | 41 | from lp.soyuz.interfaces.sourcepackageformat import ( |
211 | 41 | ISourcePackageFormatSelectionSet, SourcePackageFormat) | 42 | ISourcePackageFormatSelectionSet, SourcePackageFormat) |
212 | 42 | from lp.soyuz.model.publishing import ( | 43 | from lp.soyuz.model.publishing import ( |
213 | @@ -937,14 +938,23 @@ | |||
214 | 937 | super(DoDelayedCopyTestCase, self).setUp() | 938 | super(DoDelayedCopyTestCase, self).setUp() |
215 | 938 | self.test_publisher = SoyuzTestPublisher() | 939 | self.test_publisher = SoyuzTestPublisher() |
216 | 939 | 940 | ||
217 | 941 | # Setup to copy into the main archive security pocket | ||
218 | 942 | self.test_publisher.prepareBreezyAutotest() | ||
219 | 943 | self.copy_archive = self.test_publisher.ubuntutest.main_archive | ||
220 | 944 | self.copy_series = self.test_publisher.distroseries | ||
221 | 945 | self.copy_pocket = PackagePublishingPocket.SECURITY | ||
222 | 946 | |||
223 | 947 | # Make ubuntutest/breezy-autotest CURRENT so uploads to SECURITY | ||
224 | 948 | # pocket can be accepted. | ||
225 | 949 | self.test_publisher.breezy_autotest.status = ( | ||
226 | 950 | DistroSeriesStatus.CURRENT) | ||
227 | 951 | |||
228 | 940 | def createDelayedCopyContext(self): | 952 | def createDelayedCopyContext(self): |
229 | 941 | """Create a context to allow delayed-copies test. | 953 | """Create a context to allow delayed-copies test. |
230 | 942 | 954 | ||
231 | 943 | The returned source publication in a private archive with | 955 | The returned source publication in a private archive with |
232 | 944 | binaries and a custom upload. | 956 | binaries and a custom upload. |
233 | 945 | """ | 957 | """ |
234 | 946 | self.test_publisher.prepareBreezyAutotest() | ||
235 | 947 | |||
236 | 948 | ppa = self.factory.makeArchive( | 958 | ppa = self.factory.makeArchive( |
237 | 949 | distribution=self.test_publisher.ubuntutest, | 959 | distribution=self.test_publisher.ubuntutest, |
238 | 950 | purpose=ArchivePurpose.PPA) | 960 | purpose=ArchivePurpose.PPA) |
239 | @@ -959,34 +969,32 @@ | |||
240 | 959 | build.package_upload.addCustom( | 969 | build.package_upload.addCustom( |
241 | 960 | custom_file, PackageUploadCustomFormat.DIST_UPGRADER) | 970 | custom_file, PackageUploadCustomFormat.DIST_UPGRADER) |
242 | 961 | 971 | ||
243 | 972 | # Commit for making the just-create library files available. | ||
244 | 973 | self.layer.txn.commit() | ||
245 | 974 | |||
246 | 962 | return source | 975 | return source |
247 | 963 | 976 | ||
248 | 977 | def do_delayed_copy(self, source): | ||
249 | 978 | """Execute and return the delayed copy.""" | ||
250 | 979 | |||
251 | 980 | self.layer.switchDbUser(self.dbuser) | ||
252 | 981 | |||
253 | 982 | delayed_copy = _do_delayed_copy( | ||
254 | 983 | source, self.copy_archive, self.copy_series, self.copy_pocket, | ||
255 | 984 | True) | ||
256 | 985 | |||
257 | 986 | self.layer.txn.commit() | ||
258 | 987 | self.layer.switchDbUser('launchpad') | ||
259 | 988 | return delayed_copy | ||
260 | 989 | |||
261 | 964 | def test_do_delayed_copy_simple(self): | 990 | def test_do_delayed_copy_simple(self): |
262 | 965 | # _do_delayed_copy() return an `IPackageUpload` record configured | 991 | # _do_delayed_copy() return an `IPackageUpload` record configured |
263 | 966 | # as a delayed-copy and with the expected contents (source, | 992 | # as a delayed-copy and with the expected contents (source, |
264 | 967 | # binaries and custom uploads) in ACCEPTED state. | 993 | # binaries and custom uploads) in ACCEPTED state. |
265 | 968 | |||
266 | 969 | source = self.createDelayedCopyContext() | 994 | source = self.createDelayedCopyContext() |
267 | 970 | 995 | ||
268 | 971 | # Make ubuntutest/breezy-autotest CURRENT so uploads to SECURITY | ||
269 | 972 | # pocket can be accepted. | ||
270 | 973 | self.test_publisher.breezy_autotest.status = ( | ||
271 | 974 | DistroSeriesStatus.CURRENT) | ||
272 | 975 | |||
273 | 976 | # Setup and execute the delayed copy procedure. | 996 | # Setup and execute the delayed copy procedure. |
287 | 977 | copy_archive = self.test_publisher.ubuntutest.main_archive | 997 | delayed_copy = self.do_delayed_copy(source) |
275 | 978 | copy_series = source.distroseries | ||
276 | 979 | copy_pocket = PackagePublishingPocket.SECURITY | ||
277 | 980 | |||
278 | 981 | # Commit for making the just-create library files available. | ||
279 | 982 | self.layer.txn.commit() | ||
280 | 983 | self.layer.switchDbUser(self.dbuser) | ||
281 | 984 | |||
282 | 985 | delayed_copy = _do_delayed_copy( | ||
283 | 986 | source, copy_archive, copy_series, copy_pocket, True) | ||
284 | 987 | |||
285 | 988 | self.layer.txn.commit() | ||
286 | 989 | self.layer.switchDbUser('launchpad') | ||
288 | 990 | 998 | ||
289 | 991 | # A delayed-copy `IPackageUpload` record is returned. | 999 | # A delayed-copy `IPackageUpload` record is returned. |
290 | 992 | self.assertTrue(delayed_copy.is_delayed_copy) | 1000 | self.assertTrue(delayed_copy.is_delayed_copy) |
291 | @@ -1001,9 +1009,82 @@ | |||
292 | 1001 | delayed_copy.displayname) | 1009 | delayed_copy.displayname) |
293 | 1002 | 1010 | ||
294 | 1003 | # It is targeted to the right publishing context. | 1011 | # It is targeted to the right publishing context. |
298 | 1004 | self.assertEquals(copy_archive, delayed_copy.archive) | 1012 | self.assertEquals(self.copy_archive, delayed_copy.archive) |
299 | 1005 | self.assertEquals(copy_series, delayed_copy.distroseries) | 1013 | self.assertEquals(self.copy_series, delayed_copy.distroseries) |
300 | 1006 | self.assertEquals(copy_pocket, delayed_copy.pocket) | 1014 | self.assertEquals(self.copy_pocket, delayed_copy.pocket) |
301 | 1015 | |||
302 | 1016 | # And it contains the source, build and custom files. | ||
303 | 1017 | self.assertEquals( | ||
304 | 1018 | [source.sourcepackagerelease], | ||
305 | 1019 | [pus.sourcepackagerelease for pus in delayed_copy.sources]) | ||
306 | 1020 | |||
307 | 1021 | [build] = source.getBuilds() | ||
308 | 1022 | self.assertEquals( | ||
309 | 1023 | [build], | ||
310 | 1024 | [pub.build for pub in delayed_copy.builds]) | ||
311 | 1025 | |||
312 | 1026 | [custom_file] = [ | ||
313 | 1027 | custom.libraryfilealias | ||
314 | 1028 | for custom in build.package_upload.customfiles] | ||
315 | 1029 | self.assertEquals( | ||
316 | 1030 | [custom_file], | ||
317 | 1031 | [custom.libraryfilealias for custom in delayed_copy.customfiles]) | ||
318 | 1032 | |||
319 | 1033 | def test_do_delayed_copy_wrong_component_no_ancestry(self): | ||
320 | 1034 | """An original PPA upload for an invalid component will have been | ||
321 | 1035 | overridden when uploaded to the PPA, but when copying it to another | ||
322 | 1036 | archive, only the ancestry in the destination archive can be used. | ||
323 | 1037 | If that ancestry doesn't exist, an exception is raised.""" | ||
324 | 1038 | # We'll simulate an upload that was overridden to main in the | ||
325 | 1039 | # ppa, by explicitly setting the spr's and bpr's component to | ||
326 | 1040 | # something else. | ||
327 | 1041 | source = self.createDelayedCopyContext() | ||
328 | 1042 | contrib = getUtility(IComponentSet).new('contrib') | ||
329 | 1043 | source.sourcepackagerelease.component = contrib | ||
330 | 1044 | [build] = source.getBuilds() | ||
331 | 1045 | [binary] = build.binarypackages | ||
332 | 1046 | binary.override(component=contrib) | ||
333 | 1047 | self.layer.txn.commit() | ||
334 | 1048 | |||
335 | 1049 | # Setup and execute the delayed copy procedure. This should | ||
336 | 1050 | # raise an exception, as it won't be able to find an ancestor | ||
337 | 1051 | # whose component can be used for overriding. | ||
338 | 1052 | do_delayed_copy_method = self.do_delayed_copy | ||
339 | 1053 | self.assertRaises( | ||
340 | 1054 | QueueInconsistentStateError, do_delayed_copy_method, source) | ||
341 | 1055 | |||
342 | 1056 | def test_do_delayed_copy_wrong_component_with_ancestry(self): | ||
343 | 1057 | """An original PPA upload for an invalid component will have been | ||
344 | 1058 | overridden when uploaded to the PPA, but when copying it to another | ||
345 | 1059 | archive, only the ancestry in the destination archive can be used. | ||
346 | 1060 | If an ancestor is found in the destination archive, its component | ||
347 | 1061 | is assumed for this package upload.""" | ||
348 | 1062 | # We'll simulate an upload that was overridden to main in the | ||
349 | 1063 | # ppa, by explicitly setting the spr's and bpr's component to | ||
350 | 1064 | # something else. | ||
351 | 1065 | source = self.createDelayedCopyContext() | ||
352 | 1066 | contrib = getUtility(IComponentSet).new('contrib') | ||
353 | 1067 | source.sourcepackagerelease.component = contrib | ||
354 | 1068 | [build] = source.getBuilds() | ||
355 | 1069 | [binary] = build.binarypackages | ||
356 | 1070 | binary.override(component=contrib) | ||
357 | 1071 | |||
358 | 1072 | # This time, we'll ensure that there is already an ancestor for | ||
359 | 1073 | # foocom in the destination archive with binaries. | ||
360 | 1074 | ancestor = self.test_publisher.getPubSource( | ||
361 | 1075 | 'foocomm', '0.9', component='multiverse', | ||
362 | 1076 | archive=self.copy_archive, | ||
363 | 1077 | status=PackagePublishingStatus.PUBLISHED) | ||
364 | 1078 | ancestor_bins = self.test_publisher.getPubBinaries( | ||
365 | 1079 | binaryname='foo-bin', archive=self.copy_archive, | ||
366 | 1080 | status=PackagePublishingStatus.PUBLISHED, pub_source=ancestor) | ||
367 | 1081 | self.layer.txn.commit() | ||
368 | 1082 | |||
369 | 1083 | # Setup and execute the delayed copy procedure. This should | ||
370 | 1084 | # now result in an accepted delayed upload. | ||
371 | 1085 | delayed_copy = self.do_delayed_copy(source) | ||
372 | 1086 | self.assertEquals( | ||
373 | 1087 | PackageUploadStatus.ACCEPTED, delayed_copy.status) | ||
374 | 1007 | 1088 | ||
375 | 1008 | # And it contains the source, build and custom files. | 1089 | # And it contains the source, build and custom files. |
376 | 1009 | self.assertEquals( | 1090 | self.assertEquals( |
377 | @@ -1055,6 +1136,9 @@ | |||
378 | 1055 | changes_file_name=changes_file_name) | 1136 | changes_file_name=changes_file_name) |
379 | 1056 | package_upload.addBuild(build_i386) | 1137 | package_upload.addBuild(build_i386) |
380 | 1057 | 1138 | ||
381 | 1139 | # Commit for making the just-create library files available. | ||
382 | 1140 | self.layer.txn.commit() | ||
383 | 1141 | |||
384 | 1058 | return source | 1142 | return source |
385 | 1059 | 1143 | ||
386 | 1060 | def test_do_delayed_copy_of_partially_built_sources(self): | 1144 | def test_do_delayed_copy_of_partially_built_sources(self): |
387 | @@ -1062,17 +1146,8 @@ | |||
388 | 1062 | # the FULLYBUILT builds are copied. | 1146 | # the FULLYBUILT builds are copied. |
389 | 1063 | source = self.createPartiallyBuiltDelayedCopyContext() | 1147 | source = self.createPartiallyBuiltDelayedCopyContext() |
390 | 1064 | 1148 | ||
391 | 1065 | # Setup and execute the delayed copy procedure. | ||
392 | 1066 | copy_archive = self.test_publisher.ubuntutest.main_archive | ||
393 | 1067 | copy_series = source.distroseries | ||
394 | 1068 | copy_pocket = PackagePublishingPocket.RELEASE | ||
395 | 1069 | |||
396 | 1070 | # Make new libraryfiles available by committing the transaction. | ||
397 | 1071 | self.layer.txn.commit() | ||
398 | 1072 | |||
399 | 1073 | # Perform the delayed-copy including binaries. | 1149 | # Perform the delayed-copy including binaries. |
402 | 1074 | delayed_copy = _do_delayed_copy( | 1150 | delayed_copy = self.do_delayed_copy(source) |
401 | 1075 | source, copy_archive, copy_series, copy_pocket, True) | ||
403 | 1076 | 1151 | ||
404 | 1077 | # Only the i386 build is included in the delayed-copy. | 1152 | # Only the i386 build is included in the delayed-copy. |
405 | 1078 | # For the record, later on, when the delayed-copy gets processed, | 1153 | # For the record, later on, when the delayed-copy gets processed, |
= Summary =
We need to check which component a delayed copy *will* be overridden to, when accepting it, rather than relying on the spr.component. This is a fix for bug 475808.
== Proposed fix ==
This branch ensures that when the component of a delayed_copy is checked before accepting it, the ancestry component is taken into account (as we can't actually do the component override until we publish the source package publishing history).
== Pre-implementation notes ==
See the pre-imp notes on bug 475808
== Implementation details ==
== Tests ==
bin/test -vvt DoDelayedCopyTe stCase
== Demo and Q/A ==
We will need to Q/A this on dogfood.
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: soyuz/model/ queue.py soyuz/scripts/ tests/test_ copypackage. py
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/ soyuz/model/ queue.py MIMEMultipart' (No module named MIMEMultipart)
21: [F0401] Unable to import 'email.
22: [F0401] Unable to import 'email.MIMEText' (No module named MIMEText)
--
Michael