launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03455
[Merge] lp:~stevenk/launchpad/pdsd-cleanup into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/pdsd-cleanup into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/pdsd-cleanup/+merge/59172
Building on the work contained in devel r12899, this branch makes the method names and docstrings match the changed code.
--
https://code.launchpad.net/~stevenk/launchpad/pdsd-cleanup/+merge/59172
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/pdsd-cleanup into lp:launchpad.
=== modified file 'lib/lp/registry/scripts/populate_distroseriesdiff.py'
--- lib/lp/registry/scripts/populate_distroseriesdiff.py 2011-04-21 14:56:18 +0000
+++ lib/lp/registry/scripts/populate_distroseriesdiff.py 2011-04-27 06:45:52 +0000
@@ -224,12 +224,11 @@
(DistroSeries.parent_seriesID, DistroSeries.id))
-class BaseVersionFixer(TunableLoop):
- """Fix up `DistroSeriesDifference.base_version` in the database.
+class DSDUpdater(TunableLoop):
+ """Call `DistroSeriesDifference.update()` where appropriate.
- The code that creates `DistroSeriesDifference`s does not set the
- `base_version`. In cases where there may actually be a real base
- version, this needs to be fixed up.
+ The `DistroSeriesDifference` records we create don't have any
+ special fields set, such as base version or their diffs.
Since this is likely to be much, much slower than the rest of the
work of creating and initializing `DistroSeriesDifference`s, it is
@@ -244,7 +243,7 @@
:param commit: A commit function to call after each batch.
:param ids: Sequence of `DistroSeriesDifference` ids to fix.
"""
- super(BaseVersionFixer, self).__init__(log)
+ super(DSDUpdater, self).__init__(log)
self.minimum_chunk_size = 2
self.maximum_chunk_size = 1000
self.store = store
@@ -323,7 +322,7 @@
populate_distroseriesdiff(self.logger, distroseries)
self.commit()
self.logger.info("Updating base_versions.")
- self.fixBaseVersions(distroseries)
+ self.update(distroseries)
self.commit()
self.logger.info("Done with %s.", distroseries)
@@ -367,18 +366,17 @@
for series in self.getDistroSeries():
self.processDistroSeries(series)
- def fixBaseVersions(self, distroseries):
- """Fix up `DistroSeriesDifference.base_version` where appropriate.
+ def update(self, distroseries):
+ """Call `DistroSeriesDifference.update()` where appropriate.
- The `DistroSeriesDifference` records we create don't have their
- `base_version` fields set yet. This is a shame because it's the
- only thing we need to figure out python-side.
+ The `DistroSeriesDifference` records we create don't have any
+ special fields set, such as base version or their diffs.
Only instances where the source package is published in both the
parent series and the derived series need to have this done.
"""
self.logger.info(
- "Fixing up base_versions for %s.", distroseries.title)
+ "Updating DSDs for %s.", distroseries.title)
store = IStore(distroseries)
dsd_ids = store.find(
DistroSeriesDifference.id,
@@ -388,4 +386,4 @@
DistroSeriesDifference.difference_type ==
DistroSeriesDifferenceType.DIFFERENT_VERSIONS,
DistroSeriesDifference.base_version == None)
- BaseVersionFixer(self.logger, store, self.commit, dsd_ids).run()
+ DSDUpdater(self.logger, store, self.commit, dsd_ids).run()
=== modified file 'lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py'
--- lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py 2011-04-21 14:56:18 +0000
+++ lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py 2011-04-27 06:45:52 +0000
@@ -24,7 +24,7 @@
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.registry.model.distroseriesdifference import DistroSeriesDifference
from lp.registry.scripts.populate_distroseriesdiff import (
- BaseVersionFixer,
+ DSDUpdater,
compose_sql_difference_type,
compose_sql_find_latest_source_package_releases,
compose_sql_find_differences,
@@ -471,11 +471,11 @@
update = FakeMethod()
-class TestBaseVersionFixer(TestCase):
+class TestDSDUpdater(TestCase):
"""Test the poignant parts of `BaseVersionFixer`."""
def makeFixer(self, ids):
- fixer = BaseVersionFixer(DevNullLogger(), None, FakeMethod(), ids)
+ fixer = DSDUpdater(DevNullLogger(), None, FakeMethod(), ids)
fixer._getBatch = FakeMethod()
return fixer
@@ -589,17 +589,17 @@
spph.distroseries.distribution.name, spph.distroseries.name)
self.assertIn(expected_series_name, script.logger.getLogBuffer())
- def test_calls_fixBaseVersions(self):
+ def test_calls_update(self):
distroseries = self.makeDerivedDistroSeries()
self.makeSPPH(distroseries=distroseries)
script = self.makeScript([
'--distribution', distroseries.distribution.name,
'--series', distroseries.name,
])
- script.fixBaseVersions = FakeMethod()
+ script.update = FakeMethod()
script.main()
self.assertEqual(
- [((distroseries,), {})], script.fixBaseVersions.calls)
+ [((distroseries,), {})], script.update.calls)
def test_fixes_base_versions(self):
distroseries = self.makeDerivedDistroSeries()
@@ -622,5 +622,5 @@
script.main()
dsd = self.getDistroSeriesDiff(distroseries)[0]
dsd._updateBaseVersion = FakeMethod()
- script.fixBaseVersions(distroseries)
+ script.update(distroseries)
self.assertEqual(1, dsd._updateBaseVersion.call_count)