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
1=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
2--- lib/lp/soyuz/scripts/initialize_distroseries.py 2011-06-24 12:16:30 +0000
3+++ lib/lp/soyuz/scripts/initialize_distroseries.py 2011-07-05 10:44:15 +0000
4@@ -315,15 +315,23 @@
5 """
6 archive_set = getUtility(IArchiveSet)
7
8- spns = []
9- # The overhead from looking up each packageset is mitigated by
10- # this usually running from a job.
11- if self.packagesets:
12- for pkgsetid in self.packagesets:
13- pkgset = self._store.get(Packageset, int(pkgsetid))
14- spns += list(pkgset.getSourcesIncluded())
15-
16 for parent in self.derivation_parents:
17+ spns = []
18+ # The overhead from looking up each packageset is mitigated by
19+ # this usually running from a job.
20+ if self.packagesets:
21+ for pkgsetid in self.packagesets:
22+ pkgset = self._store.get(Packageset, int(pkgsetid))
23+ if pkgset.distroseries == parent:
24+ spns += list(pkgset.getSourcesIncluded())
25+
26+ # Some packagesets where selected but not a single
27+ # source from this parent: we skip the copy since
28+ # calling copy with spns=[] would copy all the packagesets
29+ # from this parent.
30+ if len(spns) == 0:
31+ continue
32+
33 distroarchseries_list = distroarchseries_lists[parent]
34 for archive in parent.distribution.all_distro_archives:
35 if archive.purpose not in (
36
37=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
38--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2011-06-24 12:16:30 +0000
39+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2011-07-05 10:44:15 +0000
40@@ -268,6 +268,36 @@
41 parent_srcs = test1.getSourcesIncluded(direct_inclusion=True)
42 self.assertEqual(parent_srcs, child_srcs)
43
44+ def test_copying_packagesets_multiple_parents(self):
45+ # When a packageset id is passed to the initialisation method,
46+ # only the packages in this packageset (and in the corresponding
47+ # distroseries) are copied.
48+ self.parent1, not_used = self.setupParent(
49+ packages={'udev': '0.1-1', 'firefox': '2.1'})
50+ self.parent2, not_used = self.setupParent(
51+ packages={'firefox': '3.1'})
52+ uploader = self.factory.makePerson()
53+ test1 = getUtility(IPackagesetSet).new(
54+ u'test1', u'test 1 packageset', self.parent1.owner,
55+ distroseries=self.parent1)
56+ test1.addSources('udev')
57+ test1.addSources('firefox')
58+ getUtility(IArchivePermissionSet).newPackagesetUploader(
59+ self.parent1.main_archive, uploader, test1)
60+ child = self._fullInitialize(
61+ [self.parent1, self.parent2], packagesets=(str(test1.id),))
62+ # Only the packages from the packageset test1 (from
63+ # self.parent1) are copied.
64+ published_sources = child.main_archive.getPublishedSources(
65+ distroseries=child)
66+ pub_sources = sorted(
67+ [(s.sourcepackagerelease.sourcepackagename.name,
68+ s.sourcepackagerelease.version)
69+ for s in published_sources])
70+ self.assertContentEqual(
71+ [(u'udev', u'0.1-1'), (u'firefox', u'2.1')],
72+ pub_sources)
73+
74 def test_no_cross_distro_perm_copying(self):
75 # No cross-distro archivepermissions copying should happen.
76 self.parent, self.parent_das = self.setupParent()
77@@ -704,7 +734,7 @@
78 "and no parent was passed to the initilization method"
79 ".").format(child=child),
80 ids.check)
81-
82+
83 def test_copy_method_diff_archive_empty_target(self):
84 # If the archives are different and the target archive is
85 # empty: use the cloner.