Merge lp:~rvb/launchpad/bug-805547 into lp:launchpad

Proposed by Raphaël Badin
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 13374
Proposed branch: lp:~rvb/launchpad/bug-805547
Merge into: lp:launchpad
Diff against target: 85 lines (+47/-9)
2 files modified
lib/lp/soyuz/scripts/initialize_distroseries.py (+16/-8)
lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py (+31/-1)
To merge this branch: bzr merge lp:~rvb/launchpad/bug-805547
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+66861@code.launchpad.net

Commit message

[r=gmb][bug=805547] Fix packageset's copy in initialise_distroseries.

Description of the change

This branch fixes initialise_distroseries so that only the sources from each parent is copied when a packageset's content is copied.

= Test =

./bin/test -vvc test_initialize_distroseries test_copying_packagesets_multiple_parents_same_source

= QA =

1. Make a new distro and series
2. On the initialization page (+initseries):
  * Select natty as a parent
  * Select lucid as a parent
3. Select "zope" packageset from natty
4. Select "mythbuntu" packageset from lucid
5. Click initialise

The initialisation should not fail.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
--- lib/lp/soyuz/scripts/initialize_distroseries.py 2011-06-24 12:16:30 +0000
+++ lib/lp/soyuz/scripts/initialize_distroseries.py 2011-07-05 10:44:15 +0000
@@ -315,15 +315,23 @@
315 """315 """
316 archive_set = getUtility(IArchiveSet)316 archive_set = getUtility(IArchiveSet)
317317
318 spns = []
319 # The overhead from looking up each packageset is mitigated by
320 # this usually running from a job.
321 if self.packagesets:
322 for pkgsetid in self.packagesets:
323 pkgset = self._store.get(Packageset, int(pkgsetid))
324 spns += list(pkgset.getSourcesIncluded())
325
326 for parent in self.derivation_parents:318 for parent in self.derivation_parents:
319 spns = []
320 # The overhead from looking up each packageset is mitigated by
321 # this usually running from a job.
322 if self.packagesets:
323 for pkgsetid in self.packagesets:
324 pkgset = self._store.get(Packageset, int(pkgsetid))
325 if pkgset.distroseries == parent:
326 spns += list(pkgset.getSourcesIncluded())
327
328 # Some packagesets where selected but not a single
329 # source from this parent: we skip the copy since
330 # calling copy with spns=[] would copy all the packagesets
331 # from this parent.
332 if len(spns) == 0:
333 continue
334
327 distroarchseries_list = distroarchseries_lists[parent]335 distroarchseries_list = distroarchseries_lists[parent]
328 for archive in parent.distribution.all_distro_archives:336 for archive in parent.distribution.all_distro_archives:
329 if archive.purpose not in (337 if archive.purpose not in (
330338
=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2011-06-24 12:16:30 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2011-07-05 10:44:15 +0000
@@ -268,6 +268,36 @@
268 parent_srcs = test1.getSourcesIncluded(direct_inclusion=True)268 parent_srcs = test1.getSourcesIncluded(direct_inclusion=True)
269 self.assertEqual(parent_srcs, child_srcs)269 self.assertEqual(parent_srcs, child_srcs)
270270
271 def test_copying_packagesets_multiple_parents(self):
272 # When a packageset id is passed to the initialisation method,
273 # only the packages in this packageset (and in the corresponding
274 # distroseries) are copied.
275 self.parent1, not_used = self.setupParent(
276 packages={'udev': '0.1-1', 'firefox': '2.1'})
277 self.parent2, not_used = self.setupParent(
278 packages={'firefox': '3.1'})
279 uploader = self.factory.makePerson()
280 test1 = getUtility(IPackagesetSet).new(
281 u'test1', u'test 1 packageset', self.parent1.owner,
282 distroseries=self.parent1)
283 test1.addSources('udev')
284 test1.addSources('firefox')
285 getUtility(IArchivePermissionSet).newPackagesetUploader(
286 self.parent1.main_archive, uploader, test1)
287 child = self._fullInitialize(
288 [self.parent1, self.parent2], packagesets=(str(test1.id),))
289 # Only the packages from the packageset test1 (from
290 # self.parent1) are copied.
291 published_sources = child.main_archive.getPublishedSources(
292 distroseries=child)
293 pub_sources = sorted(
294 [(s.sourcepackagerelease.sourcepackagename.name,
295 s.sourcepackagerelease.version)
296 for s in published_sources])
297 self.assertContentEqual(
298 [(u'udev', u'0.1-1'), (u'firefox', u'2.1')],
299 pub_sources)
300
271 def test_no_cross_distro_perm_copying(self):301 def test_no_cross_distro_perm_copying(self):
272 # No cross-distro archivepermissions copying should happen.302 # No cross-distro archivepermissions copying should happen.
273 self.parent, self.parent_das = self.setupParent()303 self.parent, self.parent_das = self.setupParent()
@@ -704,7 +734,7 @@
704 "and no parent was passed to the initilization method"734 "and no parent was passed to the initilization method"
705 ".").format(child=child),735 ".").format(child=child),
706 ids.check)736 ids.check)
707 737
708 def test_copy_method_diff_archive_empty_target(self):738 def test_copy_method_diff_archive_empty_target(self):
709 # If the archives are different and the target archive is739 # If the archives are different and the target archive is
710 # empty: use the cloner.740 # empty: use the cloner.