Merge lp:~wgrant/launchpad/packageset-owner-preservation into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 12701
Proposed branch: lp:~wgrant/launchpad/packageset-owner-preservation
Merge into: lp:launchpad
Diff against target: 69 lines (+34/-3)
2 files modified
lib/lp/soyuz/scripts/initialise_distroseries.py (+7/-1)
lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py (+27/-2)
To merge this branch: bzr merge lp:~wgrant/launchpad/packageset-owner-preservation
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+55466@code.launchpad.net

Commit message

[r=stevenk][bug=740892][no-qa] Preserve packageset ownership when initialising a new series within a distribution.

Description of the change

This branch fixes bug #740892, preserving packageset owners when they are inherited within a distribution. Because initialising a new distribution normally crosses a privilege boundary, the new distroseries owner is used in the case of cross-distro initialisations.

19:21 < bigjools> we can preserve it for the same distro, change it for new distros

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
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/initialise_distroseries.py'
2--- lib/lp/soyuz/scripts/initialise_distroseries.py 2011-01-15 06:32:40 +0000
3+++ lib/lp/soyuz/scripts/initialise_distroseries.py 2011-03-30 04:49:29 +0000
4@@ -285,11 +285,17 @@
5 parent_to_child = {}
6 # Create the packagesets, and any archivepermissions
7 for parent_ps in packagesets:
8+ # Cross-distro initialisations get packagesets owned by the
9+ # distro owner, otherwise the old owner is preserved.
10 if self.packagesets and parent_ps.name not in self.packagesets:
11 continue
12+ if self.distroseries.distribution == self.parent.distribution:
13+ new_owner = parent_ps.owner
14+ else:
15+ new_owner = self.distroseries.owner
16 child_ps = getUtility(IPackagesetSet).new(
17 parent_ps.name, parent_ps.description,
18- self.distroseries.owner, distroseries=self.distroseries,
19+ new_owner, distroseries=self.distroseries,
20 related_set=parent_ps)
21 self._store.execute("""
22 INSERT INTO Archivepermission
23
24=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
25--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-10-14 12:56:31 +0000
26+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2011-03-30 04:49:29 +0000
27@@ -158,8 +158,11 @@
28 child.isSourcePackageFormatPermitted(
29 SourcePackageFormat.FORMAT_1_0))
30
31- def _full_initialise(self, arches=(), packagesets=(), rebuild=False):
32- child = self.factory.makeDistroSeries(parent_series=self.parent)
33+ def _full_initialise(self, arches=(), packagesets=(), rebuild=False,
34+ distribution=None):
35+ child = self.factory.makeDistroSeries(
36+ parent_series=self.parent,
37+ distribution=distribution)
38 ids = InitialiseDistroSeries(child, arches, packagesets, rebuild)
39 ids.check()
40 ids.initialise()
41@@ -233,6 +236,28 @@
42 child.main_archive, 'udev', uploader,
43 distroseries=child))
44
45+ def test_packageset_owner_preserved_within_distro(self):
46+ # When initialising a new series within a distro, the copied
47+ # packagesets have ownership preserved.
48+ ps_owner = self.factory.makePerson()
49+ ps = getUtility(IPackagesetSet).new(
50+ u'ps', u'packageset', ps_owner, distroseries=self.parent)
51+ child = self._full_initialise(distribution=self.parent.distribution)
52+ child_ps = getUtility(IPackagesetSet).getByName(
53+ u'ps', distroseries=child)
54+ self.assertEqual(ps_owner, child_ps.owner)
55+
56+ def test_packageset_owner_not_preserved_cross_distro(self):
57+ # In the case of a cross-distro initialisation, the new
58+ # packagesets are owned by the new distro owner.
59+ ps = getUtility(IPackagesetSet).new(
60+ u'ps', u'packageset', self.factory.makePerson(),
61+ distroseries=self.parent)
62+ child = self._full_initialise()
63+ child_ps = getUtility(IPackagesetSet).getByName(
64+ u'ps', distroseries=child)
65+ self.assertEqual(child.owner, child_ps.owner)
66+
67 def test_copy_limit_packagesets(self):
68 # If a parent series has packagesets, we can decide which ones we
69 # want to copy