← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/bug-803344 into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/bug-803344 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #803344 in Launchpad itself: "Packageset permissions not inherited between distroseries"
  https://bugs.launchpad.net/launchpad/+bug/803344

For more details, see:
https://code.launchpad.net/~rvb/launchpad/bug-803344/+merge/67512

Packageset permissions are defined per-series, so they need to be copied when initialising a new series in an existing distribution.

= Tests =

./bin/test -vvc test_initialize_distroseries test_intra_distro_perm_copying

= Q/A =

Setup uploader permissions for user u on a specific packageset p in distroseries A. Initialize a new distroseries B from A and select packageset p. Make sure user has upload permissions on the new packageset p in B.
-- 
https://code.launchpad.net/~rvb/launchpad/bug-803344/+merge/67512
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/bug-803344 into lp:launchpad.
=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
--- lib/lp/soyuz/scripts/initialize_distroseries.py	2011-07-06 20:06:36 +0000
+++ lib/lp/soyuz/scripts/initialize_distroseries.py	2011-07-11 10:23:42 +0000
@@ -472,7 +472,8 @@
         packagesets = self._store.find(
             Packageset, DistroSeries.id.is_in(self.derivation_parent_ids))
         parent_to_child = {}
-        # Create the packagesets.
+        # Create the packagesets and any archivepermissions if we're not
+        # copying cross-distribution.
         parent_distro_ids = [
             parent.distribution.id for parent in self.derivation_parents]
         for parent_ps in packagesets:
@@ -494,8 +495,19 @@
                     parent_ps.name, parent_ps.description,
                     new_owner, distroseries=self.distroseries,
                     related_set=parent_ps)
-
             parent_to_child[parent_ps] = child_ps
+            # Copy archivepermissions if we're not copying
+            # cross-distribution.
+            if (self.distroseries.distribution ==
+                    parent_ps.distroseries.distribution):
+                self._store.execute("""
+                    INSERT INTO Archivepermission
+                    (person, permission, archive, packageset, explicit)
+                    SELECT person, permission, %s, %s, explicit
+                    FROM Archivepermission WHERE packageset = %s
+                    """ % sqlvalues(
+                        self.distroseries.main_archive, child_ps.id,
+                        parent_ps.id))
         # Copy the relations between sets, and the contents.
         for old_series_ps, new_series_ps in parent_to_child.items():
             old_series_sets = old_series_ps.setsIncluded(

=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py	2011-07-08 09:17:32 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py	2011-07-11 10:23:42 +0000
@@ -324,6 +324,33 @@
             [(u'udev', u'0.1-1'), (u'firefox', u'2.1')],
             pub_sources)
 
+    def test_intra_distro_perm_copying(self):
+        # If child.distribution equals parent.distribution, we also
+        # copy the archivepermissions.
+        self.parent, self.parent_das = self.setupParent()
+        uploader = self.factory.makePerson()
+        test1 = getUtility(IPackagesetSet).new(
+            u'test1', u'test 1 packageset', self.parent.owner,
+            distroseries=self.parent)
+        test1.addSources('udev')
+        getUtility(IArchivePermissionSet).newPackagesetUploader(
+            self.parent.main_archive, uploader, test1)
+        # Create child series in the same distribution.
+        child = self.factory.makeDistroSeries(
+            distribution=self.parent.distribution,
+            previous_series=self.parent)
+        self._fullInitialize([self.parent], child=child)
+
+        # The uploader can upload to the new distroseries.
+        self.assertTrue(
+            getUtility(IArchivePermissionSet).isSourceUploadAllowed(
+                self.parent.main_archive, 'udev', uploader,
+                distroseries=self.parent))
+        self.assertTrue(
+            getUtility(IArchivePermissionSet).isSourceUploadAllowed(
+                child.main_archive, 'udev', uploader,
+                distroseries=child))
+
     def test_no_cross_distro_perm_copying(self):
         # No cross-distro archivepermissions copying should happen.
         self.parent, self.parent_das = self.setupParent()