Merge lp:~julian-edwards/launchpad/auto-accept-copy-archive-binaries-bug-520520 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Merged at revision: not available
Proposed branch: lp:~julian-edwards/launchpad/auto-accept-copy-archive-binaries-bug-520520
Merge into: lp:launchpad
Diff against target: 67 lines (+31/-2)
2 files modified
lib/lp/archiveuploader/nascentupload.py (+9/-2)
lib/lp/archiveuploader/tests/test_uploadprocessor.py (+22/-0)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/auto-accept-copy-archive-binaries-bug-520520
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+20217@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

= Summary =
Add copy archive binary upload overrides.

== Proposed fix ==
This is a further tweak to my previous version of this branch that auto-
accepts COPY archive binaries. We also need to make sure that the uploaded
binary gets overrides applied from the main archive - this means it has to get
the same component as the same version in the main archive.

== Pre-implementation notes ==
Thanks to wgrant for pointing this out :)

== Implementation details ==
Partial diff here in case LP doesn't work it out:
http://pastebin.ubuntu.com/384376/

== Tests ==
bin/test -cvv test_uploadprocessor

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/archiveuploader/nascentupload.py
  lib/lp/archiveuploader/tests/test_uploadprocessor.py

Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/nascentupload.py'
2--- lib/lp/archiveuploader/nascentupload.py 2010-02-26 10:59:07 +0000
3+++ lib/lp/archiveuploader/nascentupload.py 2010-02-26 15:45:37 +0000
4@@ -582,7 +582,10 @@
5 # See the comment below, in getSourceAncestry
6 lookup_pockets = [self.policy.pocket, PackagePublishingPocket.RELEASE]
7
8- if self.policy.archive.purpose not in MAIN_ARCHIVE_PURPOSES:
9+ # If the archive is a main archive or a copy archive, we want to
10+ # look up the ancestry in all the main archives.
11+ if (self.policy.archive.purpose not in MAIN_ARCHIVE_PURPOSES and
12+ not self.policy.archive.is_copy):
13 archive = self.policy.archive
14 else:
15 archive = None
16@@ -777,7 +780,11 @@
17 # fine.
18 ancestry = self.getBinaryAncestry(
19 uploaded_file, try_other_archs=False)
20- if ancestry is not None:
21+ if (ancestry is not None and
22+ not self.policy.archive.is_copy):
23+ # Ignore version checks for copy archives
24+ # because the ancestry comes from the primary
25+ # which may have changed since the copy.
26 self.checkBinaryVersion(uploaded_file, ancestry)
27 else:
28 self.logger.debug(
29
30=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
31--- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-02-26 10:59:07 +0000
32+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-02-26 15:45:37 +0000
33@@ -548,6 +548,22 @@
34 name="bar")
35 queue_item.setDone()
36
37+ # Upload and accept a binary for the primary archive source.
38+ shutil.rmtree(upload_dir)
39+ self.options.context = 'buildd'
40+ self.options.buildid = bar_original_build.id
41+ self.layer.txn.commit()
42+ upload_dir = self.queueUpload("bar_1.0-1_binary")
43+ self.processUpload(uploadprocessor, upload_dir)
44+ self.assertEqual(
45+ uploadprocessor.last_processed_upload.is_rejected, False)
46+ bar_bin_pubs = self._publishPackage('bar', '1.0-1', source=False)
47+ # Mangle its publishing component to "restricted" so we can check
48+ # the copy archive ancestry override later.
49+ restricted = getUtility(IComponentSet)["restricted"]
50+ for pub in bar_bin_pubs:
51+ pub.secure_record.component = restricted
52+
53 # Create a COPY archive for building in non-virtual builds.
54 uploader = getUtility(IPersonSet).getByName('name16')
55 copy_archive = getUtility(IArchiveSet).new(
56@@ -586,6 +602,12 @@
57 queue_items.count(), 1,
58 "Binary upload was not accepted when it should have been.")
59
60+ # The copy archive binary published component should have been
61+ # inherited from the main archive's.
62+ copy_bin_pubs = queue_items[0].realiseUpload()
63+ for pub in copy_bin_pubs:
64+ self.assertEqual(pub.component.name, restricted.name)
65+
66 def testCopyArchiveUploadToCurrentDistro(self):
67 """Check binary copy archive uploads to RELEASE pockets.
68