← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/dsd-lose-diffs into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/dsd-lose-diffs into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/dsd-lose-diffs/+merge/55059

When a DSD is updated, the current package diffs should be invalidated, since they now contain out-of-date data. It is not in scope to request them again, since we already have UI underway to request diffs for a DSD.
-- 
https://code.launchpad.net/~stevenk/launchpad/dsd-lose-diffs/+merge/55059
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/dsd-lose-diffs into lp:launchpad.
=== modified file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py	2011-03-23 16:28:51 +0000
+++ lib/lp/registry/model/distroseriesdifference.py	2011-03-28 07:10:35 +0000
@@ -248,6 +248,11 @@
         clear_property_cache(self)
         self._updateType()
         updated = self._updateVersionsAndStatus()
+        # If the DSD has changed, we want to invalidate the diffs. The GC
+        # process for the Librarian will clean up after us.
+        if updated is True:
+            self.package_diff = None
+            self.parent_package_diff = None
         return updated
 
     def _updateType(self):

=== modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py'
--- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2011-03-24 07:43:03 +0000
+++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2011-03-28 07:10:35 +0000
@@ -441,6 +441,34 @@
         jobs = find_waiting_jobs(derived_series, source_package_name)
         self.assertEqual(0, jobs.count())
 
+    def test_update_deletes_diffs(self):
+        # When a DSD is updated, the diffs are invalidated.
+        derived_series = self.makeDerivedDistroSeries()
+        source_package_name = self.factory.makeSourcePackageName()
+        self.createPublication(
+            source_package_name, ['1.0-1derived1', '1.0-1'], derived_series)
+        self.createPublication(
+            source_package_name, ['1.0-2', '1.0-1'],
+            derived_series.parent_series)
+        spr = self.factory.makeSourcePackageRelease(
+            sourcepackagename=source_package_name, version='1.0-1')
+        self.factory.makeSourcePackagePublishingHistory(
+            sourcepackagerelease=spr,
+            archive=derived_series.parent_series.main_archive,
+            distroseries=derived_series.parent_series,
+            status=PackagePublishingStatus.SUPERSEDED)
+        jobs = find_waiting_jobs(derived_series, source_package_name)
+        self.runJob(jobs[0])
+        ds_diff = self.findDSD(derived_series, source_package_name)
+        ds_diff[0].requestPackageDiffs(self.factory.makePerson())
+        self.assertFalse(ds_diff[0].package_diff is None)
+        self.createPublication(
+            source_package_name, ['1.0-3', '1.0-2', '1.0-1'],
+            derived_series.parent_series)
+        jobs = find_waiting_jobs(derived_series, source_package_name)
+        self.runJob(jobs[0])
+        self.assertTrue(ds_diff[0].package_diff is None)
+
 
 class TestDistroSeriesDifferenceJobPermissions(TestCaseWithFactory):
     """Database permissions test for `DistroSeriesDifferenceJob`."""