Merge lp:~cjwatson/launchpad/pcj-reupload-fix into lp:launchpad

Proposed by Colin Watson on 2012-06-25
Status: Merged
Approved by: William Grant on 2012-06-25
Approved revision: no longer in the source branch.
Merged at revision: 15486
Proposed branch: lp:~cjwatson/launchpad/pcj-reupload-fix
Merge into: lp:launchpad
Diff against target: 83 lines (+20/-14)
2 files modified
lib/lp/soyuz/scripts/packagecopier.py (+17/-13)
lib/lp/soyuz/tests/test_packagecopyjob.py (+3/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/pcj-reupload-fix
Reviewer Review Type Date Requested Status
William Grant code 2012-06-25 Approve on 2012-06-25
Review via email: mp+111804@code.launchpad.net

Commit Message

Unembargo direct-copied files after calling notify, so that changelog-based notification is possible.

Description of the Change

== Summary ==

https://code.launchpad.net/~cjwatson/launchpad/pcj-reupload/+merge/111124 didn't quite work, as indicated in the QA notes on bug 334858.

== Proposed fix ==

Add the missing transaction.commit. We didn't notice this in tests because the test in question didn't set SPR.changelog, so fix that too.

== LOC Rationale ==

+6. Same rationale as https://code.launchpad.net/~cjwatson/launchpad/pcj-reupload/+merge/111124.

== Tests ==

bin/test -vvct test_packagecopyjob

== Demo and Q/A ==

Same as https://code.launchpad.net/~cjwatson/launchpad/pcj-reupload/+merge/111124.

To post a comment you must log in.
William Grant (wgrant) :
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/soyuz/scripts/packagecopier.py'
2--- lib/lp/soyuz/scripts/packagecopier.py 2012-06-22 23:55:02 +0000
3+++ lib/lp/soyuz/scripts/packagecopier.py 2012-06-25 10:51:19 +0000
4@@ -677,13 +677,28 @@
5 include_binaries, override, close_bugs=close_bugs,
6 create_dsd_job=create_dsd_job,
7 close_bugs_since_version=old_version, creator=creator,
8- sponsor=sponsor, packageupload=packageupload, logger=logger)
9+ sponsor=sponsor, packageupload=packageupload)
10 if send_email:
11 notify(
12 person, source.sourcepackagerelease, [], [], archive,
13 destination_series, pocket, action='accepted',
14 announce_from_person=announce_from_person,
15 previous_version=old_version)
16+ if not archive.private and has_restricted_files(source):
17+ # Fix copies by overriding them according to the current
18+ # ancestry and re-upload files with privacy mismatch. We
19+ # must do this *after* calling notify (which only actually
20+ # sends mail on commit), because otherwise the new changelog
21+ # LFA won't be visible without a commit, which may not be
22+ # safe here.
23+ for pub_record in sub_copies:
24+ pub_record.overrideFromAncestry()
25+ for new_file in update_files_privacy(pub_record):
26+ if logger is not None:
27+ logger.info(
28+ "Re-uploaded %s to librarian" %
29+ new_file.filename)
30+
31
32 overrides_index += 1
33 copies.extend(sub_copies)
34@@ -694,7 +709,7 @@
35 def _do_direct_copy(source, archive, series, pocket, include_binaries,
36 override=None, close_bugs=True, create_dsd_job=True,
37 close_bugs_since_version=None, creator=None,
38- sponsor=None, packageupload=None, logger=None):
39+ sponsor=None, packageupload=None):
40 """Copy publishing records to another location.
41
42 Copy each item of the given list of `SourcePackagePublishingHistory`
43@@ -724,7 +739,6 @@
44 :param sponsor: the sponsor `IPerson`, if this copy is being sponsored.
45 :param packageupload: The `IPackageUpload` that caused this publication
46 to be created.
47- :param logger: An optional logger.
48
49 :return: a list of `ISourcePackagePublishingHistory` and
50 `BinaryPackagePublishingHistory` corresponding to the copied
51@@ -781,16 +795,6 @@
52 # XXX cjwatson 2012-06-22 bug=869308: Fails to honour P-a-s.
53 source_copy.createMissingBuilds()
54
55- if not archive.private and has_restricted_files(source):
56- # Fix copies by overriding them according to the current ancestry
57- # and re-upload files with privacy mismatch.
58- for pub_record in copies:
59- pub_record.overrideFromAncestry()
60- for new_file in update_files_privacy(pub_record):
61- if logger is not None:
62- logger.info(
63- "Re-uploaded %s to librarian" % new_file.filename)
64-
65 return copies
66
67
68
69=== modified file 'lib/lp/soyuz/tests/test_packagecopyjob.py'
70--- lib/lp/soyuz/tests/test_packagecopyjob.py 2012-06-19 23:49:20 +0000
71+++ lib/lp/soyuz/tests/test_packagecopyjob.py 2012-06-25 10:51:19 +0000
72@@ -1118,8 +1118,10 @@
73 version="2.8-1", status=PackagePublishingStatus.PUBLISHED,
74 component='multiverse', section='web',
75 archive=source_archive)
76- for source_file in spph.sourcepackagerelease.files:
77+ spr = spph.sourcepackagerelease
78+ for source_file in spr.files:
79 self.assertTrue(source_file.libraryfile.restricted)
80+ spr.changelog = self.factory.makeLibraryFileAlias(restricted=True)
81
82 # Now, run the copy job.
83 source = getUtility(IPlainPackageCopyJobSource)