Merge lp:~julian-edwards/launchpad/sync-close-bugs-bug-833736 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 13886
Proposed branch: lp:~julian-edwards/launchpad/sync-close-bugs-bug-833736
Merge into: lp:launchpad
Diff against target: 179 lines (+71/-29)
3 files modified
lib/lp/soyuz/interfaces/archive.py (+3/-5)
lib/lp/soyuz/scripts/processaccepted.py (+10/-5)
lib/lp/soyuz/scripts/tests/test_processaccepted.py (+58/-19)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/sync-close-bugs-bug-833736
Reviewer Review Type Date Requested Status
Julian Edwards Pending
Review via email: mp+74117@code.launchpad.net

Commit message

[r=julian-edwards][bug=833736] When closing bugs on package syncs, fix a bug that prevented closing bugs in a different distroseries source package to the original upload distroseries on the sourcepackagerelease.

Description of the change

Fix an additional bug in the original branch that prevented closure of bugs that are in a different distroseries package to the original uploaded distroseries.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py 2011-08-30 14:54:57 +0000
+++ lib/lp/soyuz/interfaces/archive.py 2011-09-06 10:47:26 +0000
@@ -1245,17 +1245,15 @@
1245 @operation_for_version('devel')1245 @operation_for_version('devel')
1246 def copyPackages(source_names, from_archive, to_pocket, person,1246 def copyPackages(source_names, from_archive, to_pocket, person,
1247 to_series=None, include_binaries=False):1247 to_series=None, include_binaries=False):
1248 """Atomically copy named sources into this archive from another.1248 """Copy multiple named sources into this archive from another.
12491249
1250 Asynchronously copy the most recent PUBLISHED versions of the named1250 Asynchronously copy the most recent PUBLISHED versions of the named
1251 sources to the destination archive if necessary. Calls to this1251 sources to the destination archive if necessary. Calls to this
1252 method will return immediately if the copy passes basic security1252 method will return immediately if the copy passes basic security
1253 checks and the copy will happen sometime later with full checking.1253 checks and the copy will happen sometime later with full checking.
12541254
1255 This operation will only succeed when all requested packages1255 Partial changes of the destination archive can happen because each
1256 are synchronised between the archives. If any of the requested1256 source is copied in its own transaction.
1257 copies cannot be performed, the whole operation will fail. There
1258 will be no partial changes of the destination archive.
12591257
1260 :param source_names: a list of string names of packages to copy.1258 :param source_names: a list of string names of packages to copy.
1261 :param from_archive: the source archive from which to copy.1259 :param from_archive: the source archive from which to copy.
12621260
=== modified file 'lib/lp/soyuz/scripts/processaccepted.py'
--- lib/lp/soyuz/scripts/processaccepted.py 2011-08-31 11:58:28 +0000
+++ lib/lp/soyuz/scripts/processaccepted.py 2011-09-06 10:47:26 +0000
@@ -164,11 +164,13 @@
164 changesfile_object = sourcepackagerelease.upload_changesfile164 changesfile_object = sourcepackagerelease.upload_changesfile
165165
166 close_bugs_for_sourcepackagerelease(166 close_bugs_for_sourcepackagerelease(
167 sourcepackagerelease, changesfile_object, since_version)167 sourcepackagerelease, changesfile_object, since_version,
168 upload_distroseries=source_publication.distroseries)
168169
169170
170def close_bugs_for_sourcepackagerelease(source_release, changesfile_object,171def close_bugs_for_sourcepackagerelease(source_release, changesfile_object,
171 since_version=None):172 since_version=None,
173 upload_distroseries=None):
172 """Close bugs for a given source.174 """Close bugs for a given source.
173175
174 Given a `ISourcePackageRelease` and a corresponding changesfile object,176 Given a `ISourcePackageRelease` and a corresponding changesfile object,
@@ -203,10 +205,13 @@
203 # here, BE CAREFUL with the unproxied bug object and look at205 # here, BE CAREFUL with the unproxied bug object and look at
204 # what you're doing with it that might violate security.206 # what you're doing with it that might violate security.
205 bug = removeSecurityProxy(bug)207 bug = removeSecurityProxy(bug)
208 if upload_distroseries is not None:
209 target = upload_distroseries.getSourcePackage(
210 source_release.sourcepackagename)
211 else:
212 target = source_release.sourcepackage
206 edited_task = bug.setStatus(213 edited_task = bug.setStatus(
207 target=source_release.sourcepackage,214 target=target, status=BugTaskStatus.FIXRELEASED, user=janitor)
208 status=BugTaskStatus.FIXRELEASED,
209 user=janitor)
210 if edited_task is not None:215 if edited_task is not None:
211 assert source_release.changelog_entry is not None, (216 assert source_release.changelog_entry is not None, (
212 "New source uploads should have a changelog.")217 "New source uploads should have a changelog.")
213218
=== modified file 'lib/lp/soyuz/scripts/tests/test_processaccepted.py'
--- lib/lp/soyuz/scripts/tests/test_processaccepted.py 2011-08-29 17:02:01 +0000
+++ lib/lp/soyuz/scripts/tests/test_processaccepted.py 2011-09-06 10:47:26 +0000
@@ -8,8 +8,10 @@
88
9from canonical.testing.layers import LaunchpadZopelessLayer9from canonical.testing.layers import LaunchpadZopelessLayer
10from lp.bugs.interfaces.bugtask import BugTaskStatus10from lp.bugs.interfaces.bugtask import BugTaskStatus
11from lp.registry.interfaces.pocket import PackagePublishingPocket
11from lp.soyuz.scripts.processaccepted import (12from lp.soyuz.scripts.processaccepted import (
12 close_bugs_for_sourcepackagerelease,13 close_bugs_for_sourcepackagerelease,
14 close_bugs_for_sourcepublication,
13 )15 )
14from lp.testing import TestCaseWithFactory16from lp.testing import TestCaseWithFactory
1517
@@ -27,28 +29,30 @@
27 """29 """
28 layer = LaunchpadZopelessLayer30 layer = LaunchpadZopelessLayer
2931
30 def test_close_bugs_for_sourcepackagerelease_with_no_changes_file(self):32 def makeChangelogWithBugs(self, spr, target_series=None):
31 # If there's no changes file it should read the changelog_entry on33 """Create a changelog for the passed sourcepackagerelease that has
32 # the sourcepackagerelease.34 6 bugs referenced.
3335
34 spr = self.factory.makeSourcePackageRelease(changelog_entry="blah")36 :param spr: The sourcepackagerelease that needs a changelog.
3537 :param target_distro: the distribution context for the source package
38 bug target. If None, default to its uploaded distribution.
39
40 :return: A tuple which is a list of (bug, bugtask)
41 """
36 # Make 4 bugs and corresponding bugtasks and put them in an array42 # Make 4 bugs and corresponding bugtasks and put them in an array
37 # as tuples.43 # as tuples.
38 bugs = []44 bugs = []
39 for i in range(5):45 for i in range(6):
46 if target_series is None:
47 target = spr.sourcepackage
48 else:
49 target = target_series.getSourcePackage(spr.sourcepackagename)
40 bug = self.factory.makeBug()50 bug = self.factory.makeBug()
41 bugtask = self.factory.makeBugTask(51 bugtask = self.factory.makeBugTask(target=target, bug=bug)
42 target=spr.sourcepackage, bug=bug)
43 bugs.append((bug, bugtask))52 bugs.append((bug, bugtask))
44
45 unfixed_bug = self.factory.makeBug()
46 unfixed_task = self.factory.makeBugTask(
47 target=spr.sourcepackage, bug=unfixed_bug)
48
49 # Make a changelog entry for a package which contains the IDs of53 # Make a changelog entry for a package which contains the IDs of
50 # the 5 bugs separated across 2 releases.54 # the 6 bugs separated across 3 releases.
51 changelog=dedent("""55 changelog = dedent("""
52 foo (1.0-3) unstable; urgency=low56 foo (1.0-3) unstable; urgency=low
5357
54 * closes: %s, %s58 * closes: %s, %s
@@ -74,18 +78,53 @@
74 bugs[2][0].id,78 bugs[2][0].id,
75 bugs[3][0].id,79 bugs[3][0].id,
76 bugs[4][0].id,80 bugs[4][0].id,
77 unfixed_bug.id,81 bugs[5][0].id,
78 ))82 ))
79 lfa = self.factory.makeLibraryFileAlias(content=changelog)83 lfa = self.factory.makeLibraryFileAlias(content=changelog)
80
81 removeSecurityProxy(spr).changelog = lfa84 removeSecurityProxy(spr).changelog = lfa
82 self.layer.txn.commit()85 self.layer.txn.commit()
86 return bugs
87
88 def test_close_bugs_for_sourcepackagerelease_with_no_changes_file(self):
89 # If there's no changes file it should read the changelog_entry on
90 # the sourcepackagerelease.
91
92 spr = self.factory.makeSourcePackageRelease(changelog_entry="blah")
93 bugs = self.makeChangelogWithBugs(spr)
8394
84 # Call the method and test it's closed the bugs.95 # Call the method and test it's closed the bugs.
85 close_bugs_for_sourcepackagerelease(spr, changesfile_object=None,96 close_bugs_for_sourcepackagerelease(spr, changesfile_object=None,
86 since_version="1.0-1")97 since_version="1.0-1")
87 for bug, bugtask in bugs:98 for bug, bugtask in bugs:
99 if bug.id != bugs[5][0].id:
100 self.assertEqual(BugTaskStatus.FIXRELEASED, bugtask.status)
101 else:
102 self.assertEqual(BugTaskStatus.NEW, bugtask.status)
103
104 def test__close_bugs_for_sourcepublication__uses_right_distro(self):
105 # If a source was originally uploaded to a different distro,
106 # closing bugs based on a publication of the same source in a new
107 # distro should work.
108
109 # Create a source package that was originally uploaded to one
110 # distro and publish it in a second distro.
111 spr = self.factory.makeSourcePackageRelease(changelog_entry="blah")
112 target_distro = self.factory.makeDistribution()
113 target_distroseries = self.factory.makeDistroSeries(target_distro)
114 bugs = self.makeChangelogWithBugs(
115 spr, target_series=target_distroseries)
116 target_spph = self.factory.makeSourcePackagePublishingHistory(
117 sourcepackagerelease=spr, distroseries=target_distroseries,
118 archive=target_distro.main_archive,
119 pocket=PackagePublishingPocket.RELEASE)
120
121 # The test depends on this pre-condition.
122 self.assertNotEqual(spr.upload_distroseries.distribution,
123 target_distroseries.distribution)
124
125 close_bugs_for_sourcepublication(target_spph, since_version="1.0")
126
127 for bug, bugtask in bugs:
88 self.assertEqual(BugTaskStatus.FIXRELEASED, bugtask.status)128 self.assertEqual(BugTaskStatus.FIXRELEASED, bugtask.status)
89129
90 self.assertEqual(BugTaskStatus.NEW, unfixed_task.status)
91130