Merge lp:~stevenk/launchpad/pdsd-cleanup into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 12929
Proposed branch: lp:~stevenk/launchpad/pdsd-cleanup
Merge into: lp:launchpad
Diff against target: 122 lines (+18/-20)
2 files modified
lib/lp/registry/scripts/populate_distroseriesdiff.py (+11/-13)
lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py (+7/-7)
To merge this branch: bzr merge lp:~stevenk/launchpad/pdsd-cleanup
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Review via email: mp+59172@code.launchpad.net

Commit message

[r=jtv][no-qa] Clean up PopulateDistroSeriesDifference by having docstrings and method names match code and intent.

Description of the change

Building on the work contained in devel r12899, this branch makes the method names and docstrings match the changed code.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Thanks for cleaning it up.

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/registry/scripts/populate_distroseriesdiff.py'
2--- lib/lp/registry/scripts/populate_distroseriesdiff.py 2011-04-21 14:56:18 +0000
3+++ lib/lp/registry/scripts/populate_distroseriesdiff.py 2011-04-27 07:45:06 +0000
4@@ -224,12 +224,11 @@
5 (DistroSeries.parent_seriesID, DistroSeries.id))
6
7
8-class BaseVersionFixer(TunableLoop):
9- """Fix up `DistroSeriesDifference.base_version` in the database.
10+class DSDUpdater(TunableLoop):
11+ """Call `DistroSeriesDifference.update()` where appropriate.
12
13- The code that creates `DistroSeriesDifference`s does not set the
14- `base_version`. In cases where there may actually be a real base
15- version, this needs to be fixed up.
16+ The `DistroSeriesDifference` records we create don't have their
17+ details filled out, such as base version or their diffs.
18
19 Since this is likely to be much, much slower than the rest of the
20 work of creating and initializing `DistroSeriesDifference`s, it is
21@@ -244,7 +243,7 @@
22 :param commit: A commit function to call after each batch.
23 :param ids: Sequence of `DistroSeriesDifference` ids to fix.
24 """
25- super(BaseVersionFixer, self).__init__(log)
26+ super(DSDUpdater, self).__init__(log)
27 self.minimum_chunk_size = 2
28 self.maximum_chunk_size = 1000
29 self.store = store
30@@ -323,7 +322,7 @@
31 populate_distroseriesdiff(self.logger, distroseries)
32 self.commit()
33 self.logger.info("Updating base_versions.")
34- self.fixBaseVersions(distroseries)
35+ self.update(distroseries)
36 self.commit()
37 self.logger.info("Done with %s.", distroseries)
38
39@@ -367,18 +366,17 @@
40 for series in self.getDistroSeries():
41 self.processDistroSeries(series)
42
43- def fixBaseVersions(self, distroseries):
44- """Fix up `DistroSeriesDifference.base_version` where appropriate.
45+ def update(self, distroseries):
46+ """Call `DistroSeriesDifference.update()` where appropriate.
47
48 The `DistroSeriesDifference` records we create don't have their
49- `base_version` fields set yet. This is a shame because it's the
50- only thing we need to figure out python-side.
51+ details filled out, such as base version or their diffs.
52
53 Only instances where the source package is published in both the
54 parent series and the derived series need to have this done.
55 """
56 self.logger.info(
57- "Fixing up base_versions for %s.", distroseries.title)
58+ "Updating DSDs for %s.", distroseries.title)
59 store = IStore(distroseries)
60 dsd_ids = store.find(
61 DistroSeriesDifference.id,
62@@ -388,4 +386,4 @@
63 DistroSeriesDifference.difference_type ==
64 DistroSeriesDifferenceType.DIFFERENT_VERSIONS,
65 DistroSeriesDifference.base_version == None)
66- BaseVersionFixer(self.logger, store, self.commit, dsd_ids).run()
67+ DSDUpdater(self.logger, store, self.commit, dsd_ids).run()
68
69=== modified file 'lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py'
70--- lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py 2011-04-21 14:56:18 +0000
71+++ lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py 2011-04-27 07:45:06 +0000
72@@ -24,7 +24,7 @@
73 from lp.registry.interfaces.pocket import PackagePublishingPocket
74 from lp.registry.model.distroseriesdifference import DistroSeriesDifference
75 from lp.registry.scripts.populate_distroseriesdiff import (
76- BaseVersionFixer,
77+ DSDUpdater,
78 compose_sql_difference_type,
79 compose_sql_find_latest_source_package_releases,
80 compose_sql_find_differences,
81@@ -471,11 +471,11 @@
82 update = FakeMethod()
83
84
85-class TestBaseVersionFixer(TestCase):
86+class TestDSDUpdater(TestCase):
87 """Test the poignant parts of `BaseVersionFixer`."""
88
89 def makeFixer(self, ids):
90- fixer = BaseVersionFixer(DevNullLogger(), None, FakeMethod(), ids)
91+ fixer = DSDUpdater(DevNullLogger(), None, FakeMethod(), ids)
92 fixer._getBatch = FakeMethod()
93 return fixer
94
95@@ -589,17 +589,17 @@
96 spph.distroseries.distribution.name, spph.distroseries.name)
97 self.assertIn(expected_series_name, script.logger.getLogBuffer())
98
99- def test_calls_fixBaseVersions(self):
100+ def test_calls_update(self):
101 distroseries = self.makeDerivedDistroSeries()
102 self.makeSPPH(distroseries=distroseries)
103 script = self.makeScript([
104 '--distribution', distroseries.distribution.name,
105 '--series', distroseries.name,
106 ])
107- script.fixBaseVersions = FakeMethod()
108+ script.update = FakeMethod()
109 script.main()
110 self.assertEqual(
111- [((distroseries,), {})], script.fixBaseVersions.calls)
112+ [((distroseries,), {})], script.update.calls)
113
114 def test_fixes_base_versions(self):
115 distroseries = self.makeDerivedDistroSeries()
116@@ -622,5 +622,5 @@
117 script.main()
118 dsd = self.getDistroSeriesDiff(distroseries)[0]
119 dsd._updateBaseVersion = FakeMethod()
120- script.fixBaseVersions(distroseries)
121+ script.update(distroseries)
122 self.assertEqual(1, dsd._updateBaseVersion.call_count)