← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/launchpad/pre-747546 into lp:launchpad

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/pre-747546 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
  Bug #747546 in Launchpad itself: "Derived Distros: Add a button to sync all packages changed in parent but not changed in child"
  https://bugs.launchpad.net/launchpad/+bug/747546

For more details, see:
https://code.launchpad.net/~jtv/launchpad/pre-747546/+merge/59771

Cleaning up some lint to keep those changes out of the main MP for bug 747546.

The "html" identifiers were bad because the same test also imported a module called html.
-- 
https://code.launchpad.net/~jtv/launchpad/pre-747546/+merge/59771
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/pre-747546 into lp:launchpad.
=== modified file 'lib/canonical/launchpad/components/decoratedresultset.py'
--- lib/canonical/launchpad/components/decoratedresultset.py	2011-03-22 00:18:47 +0000
+++ lib/canonical/launchpad/components/decoratedresultset.py	2011-05-03 12:41:23 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 # pylint: disable-msg=E0611,W0212
@@ -37,9 +37,14 @@
     def __init__(self, result_set, result_decorator=None, pre_iter_hook=None,
                  slice_info=False):
         """
+        Wrap `result_set` in a decorator.
+
+        The decorator will act as a result set where a result row `self[x]`
+        is really `result_decorator(result_set[x])`.
+
         :param result_set: The original result set to be decorated.
-        :param result_decorator: The method with which individual results
-            will be passed through before being returned.
+        :param result_decorator: A transformation function that individual
+            results will be passed through.
         :param pre_iter_hook: The method to be called (with the 'result_set')
             immediately before iteration starts. The return value of the hook
             is ignored.

=== modified file 'lib/canonical/launchpad/doc/decoratedresultset.txt'
--- lib/canonical/launchpad/doc/decoratedresultset.txt	2010-11-06 12:08:24 +0000
+++ lib/canonical/launchpad/doc/decoratedresultset.txt	2011-05-03 12:41:23 +0000
@@ -22,9 +22,9 @@
     >>> from lp.registry.model.distribution import Distribution
     >>> result_set = store.find(Distribution)
 
-== Creating the decorator method ==
+== Creating the decorator function ==
 
-We create a decorator method that we want to be applied to any
+We create a decorator function that we want to be applied to any
 results obtained from our undecorated result set. For instance,
 we can turn a model object into a string:
 
@@ -80,7 +80,7 @@
     >>> from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
     >>> from lp.soyuz.model.publishing import BinaryPackagePublishingHistory
     >>> results = store.find(BinaryPackageRelease,
-    ...     BinaryPackageRelease.id == 
+    ...     BinaryPackageRelease.id ==
     ...         BinaryPackagePublishingHistory.binarypackagereleaseID)
     >>> results = results.config(distinct=True)
     >>> len(list(results))

=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py	2011-04-27 07:27:55 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py	2011-05-03 12:41:23 +0000
@@ -110,7 +110,7 @@
         # Helper function to create a valid DSD.
         distroseries = self.factory.makeDistroSeries(
             parent_series=self.factory.makeDistroSeries())
-        ds_diff = self.factory.makeDistroSeriesDifference(
+        self.factory.makeDistroSeriesDifference(
             derived_series=distroseries, difference_type=difference_type)
         return create_initialized_view(distroseries, '+index')
 
@@ -173,11 +173,11 @@
                 derived_series,
                 '+index',
                 principal=self.simple_user)
-            html = view()
+            html_text = view()
 
         self.assertEqual(
             None, getFeatureFlag('soyuz.derived-series-ui.enabled'))
-        self.assertThat(html, Not(portlet_header))
+        self.assertThat(html_text, Not(portlet_header))
 
     def test_differences_portlet_all_differences(self):
         # The difference portlet shows the differences with the parent
@@ -209,9 +209,9 @@
             # XXX rvb 2011-04-12 bug=758649: LaunchpadTestRequest overrides
             # self.features to NullFeatureController.
             view.request.features = get_relevant_feature_controller()
-            html = view()
+            html_text = view()
 
-        self.assertThat(html, portlet_display)
+        self.assertThat(html_text, portlet_display)
 
     def test_differences_portlet_no_differences(self):
         # The difference portlet displays 'No differences' if there is no
@@ -235,9 +235,9 @@
             # XXX rvb 2011-04-12 bug=758649: LaunchpadTestRequest overrides
             # self.features to NullFeatureController.
             view.request.features = get_relevant_feature_controller()
-            html = view()
+            html_text = view()
 
-        self.assertThat(html, portlet_display)
+        self.assertThat(html_text, portlet_display)
 
     def test_differences_portlet_initialising(self):
         # The difference portlet displays 'The series is initialising.' if
@@ -245,7 +245,7 @@
         set_derived_series_ui_feature_flag(self)
         derived_series = self._setupDifferences('deri', 'sid', 0, 0, 0)
         job_source = getUtility(IInitialiseDistroSeriesJobSource)
-        job = job_source.create(derived_series.parent, derived_series)
+        job_source.create(derived_series.parent, derived_series)
         portlet_display = soupmatchers.HTMLContains(
             soupmatchers.Tag(
                 'Derived series', 'h2',
@@ -263,10 +263,10 @@
             # XXX rvb 2011-04-12 bug=758649: LaunchpadTestRequest overrides
             # self.features to NullFeatureController.
             view.request.features = get_relevant_feature_controller()
-            html = view()
+            html_text = view()
 
         self.assertTrue(derived_series.is_initialising)
-        self.assertThat(html, portlet_display)
+        self.assertThat(html_text, portlet_display)
 
 
 class TestMilestoneBatchNavigatorAttribute(TestCaseWithFactory):
@@ -401,7 +401,7 @@
 class DistroSeriesDifferenceMixin:
     """A helper class for testing differences pages"""
 
-    def _test_packagesets(self, html, packageset_text,
+    def _test_packagesets(self, html_text, packageset_text,
                           packageset_class, msg_text):
         parent_packagesets = soupmatchers.HTMLContains(
             soupmatchers.Tag(
@@ -409,7 +409,7 @@
                 attrs={'class': packageset_class},
                 text=packageset_text))
 
-        self.assertThat(html, parent_packagesets)
+        self.assertThat(html_text, parent_packagesets)
 
 
 class TestDistroSeriesLocalDifferences(
@@ -471,11 +471,12 @@
                 ds_diff.derived_series,
                 '+localpackagediffs',
                 principal=self.simple_user)
-            html = view()
+            html_text = view()
 
         packageset_text = re.compile('\s*' + ps.name)
         self._test_packagesets(
-            html, packageset_text, 'parent-packagesets', 'Parent packagesets')
+            html_text, packageset_text, 'parent-packagesets',
+            'Parent packagesets')
 
     def test_parent_packagesets_localpackagediffs_sorts(self):
         # Multiple packagesets are sorted in a comma separated list.
@@ -493,12 +494,13 @@
                 ds_diff.derived_series,
                 '+localpackagediffs',
                 principal=self.simple_user)
-            html = view()
+            html_text = view()
 
         packageset_text = re.compile(
             '\s*' + ', '.join(sorted(unsorted_names)))
         self._test_packagesets(
-            html, packageset_text, 'parent-packagesets', 'Parent packagesets')
+            html_text, packageset_text, 'parent-packagesets',
+            'Parent packagesets')
 
     def test_queries(self):
         # With no DistroSeriesDifferences the query count should be low and
@@ -1228,11 +1230,12 @@
                 self.ds_diff.derived_series,
                 '+missingpackages',
                 principal=self.simple_user)
-            html = view()
+            html_text = view()
 
         packageset_text = re.compile('\s*' + ps.name)
         self._test_packagesets(
-            html, packageset_text, 'parent-packagesets', 'Parent packagesets')
+            html_text, packageset_text, 'parent-packagesets',
+            'Parent packagesets')
 
 
 class DistroSerieUniquePackageDiffsTestCase(TestCaseWithFactory):
@@ -1314,8 +1317,8 @@
                 self.ds_diff.derived_series,
                 '+uniquepackages',
                 principal=self.simple_user)
-            html = view()
+            html_text = view()
 
         packageset_text = re.compile('\s*' + ps.name)
         self._test_packagesets(
-            html, packageset_text, 'packagesets', 'Packagesets')
+            html_text, packageset_text, 'packagesets', 'Packagesets')

=== modified file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py	2011-04-22 00:58:35 +0000
+++ lib/lp/registry/model/distroseriesdifference.py	2011-05-03 12:41:23 +0000
@@ -277,29 +277,26 @@
             And(*conditions)).order_by(SourcePackageName.name)
 
         def eager_load(dsds):
+            active_statuses = (
+                PackagePublishingStatus.PUBLISHED,
+                PackagePublishingStatus.PENDING,
+                )
             source_pubs = dict(
                 most_recent_publications(
-                    dsds, in_parent=False, statuses=(
-                        PackagePublishingStatus.PUBLISHED,
-                        PackagePublishingStatus.PENDING)))
+                    dsds, statuses=active_statuses,
+                    in_parent=False, match_version=False))
             parent_source_pubs = dict(
                 most_recent_publications(
-                    dsds, in_parent=True, statuses=(
-                        PackagePublishingStatus.PUBLISHED,
-                        PackagePublishingStatus.PENDING)))
-
+                    dsds, statuses=active_statuses,
+                    in_parent=True, match_version=False))
             source_pubs_for_release = dict(
                 most_recent_publications(
-                    dsds, in_parent=False, statuses=(
-                        PackagePublishingStatus.PUBLISHED,
-                        PackagePublishingStatus.PENDING),
-                    match_version=True))
+                    dsds, statuses=active_statuses,
+                    in_parent=False, match_version=True))
             parent_source_pubs_for_release = dict(
                 most_recent_publications(
-                    dsds, in_parent=True, statuses=(
-                        PackagePublishingStatus.PUBLISHED,
-                        PackagePublishingStatus.PENDING),
-                    match_version=True))
+                    dsds, statuses=active_statuses,
+                    in_parent=True, match_version=True))
 
             latest_comment_by_dsd_id = dict(
                 (comment.distro_series_difference_id, comment)