Merge lp:~lifeless/launchpad/bug-279513 into lp:launchpad
- bug-279513
- Merge into devel
Status: | Work in progress |
---|---|
Proposed branch: | lp:~lifeless/launchpad/bug-279513 |
Merge into: | lp:launchpad |
Diff against target: |
427 lines (+63/-173) 11 files modified
lib/lp/bugs/browser/bugtask.py (+28/-15) lib/lp/bugs/browser/tests/bugtask-target-link-titles.txt (+4/-2) lib/lp/bugs/stories/bugs/xx-bug-index.txt (+15/-3) lib/lp/registry/browser/product.py (+2/-2) lib/lp/registry/interfaces/distribution.py (+0/-19) lib/lp/registry/model/distribution.py (+0/-58) lib/lp/registry/model/distributionsourcepackage.py (+4/-2) lib/lp/registry/tests/test_distribution.py (+0/-66) lib/lp/registry/tests/test_distroseries.py (+5/-5) lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt (+4/-1) lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt (+1/-0) |
To merge this branch: | bzr merge lp:~lifeless/launchpad/bug-279513 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
j.c.sackett (community) | Approve | ||
William Grant | code* | Approve | |
Review via email: mp+51063@code.launchpad.net |
Commit message
[r=jcsackett,
Description of the change
Distribution.
We could alternatively make Distribution.
j.c.sackett (jcsackett) wrote : | # |
This looks good to land.
Robert Collins (lifeless) wrote : | # |
I'm abandoning this - its a bit of a rabbit warren, and the perf wins are relatively small compared to the initial work. We are really broken right now, but this is something to do when things are fast, not right now.
Preview Diff
1 | === modified file 'lib/lp/bugs/browser/bugtask.py' | |||
2 | --- lib/lp/bugs/browser/bugtask.py 2011-03-01 05:05:26 +0000 | |||
3 | +++ lib/lp/bugs/browser/bugtask.py 2011-03-02 05:19:17 +0000 | |||
4 | @@ -250,7 +250,6 @@ | |||
5 | 250 | from lp.bugs.interfaces.malone import IMaloneApplication | 250 | from lp.bugs.interfaces.malone import IMaloneApplication |
6 | 251 | from lp.registry.interfaces.distribution import ( | 251 | from lp.registry.interfaces.distribution import ( |
7 | 252 | IDistribution, | 252 | IDistribution, |
8 | 253 | IDistributionSet, | ||
9 | 254 | ) | 253 | ) |
10 | 255 | from lp.registry.interfaces.distributionsourcepackage import ( | 254 | from lp.registry.interfaces.distributionsourcepackage import ( |
11 | 256 | IDistributionSourcePackage, | 255 | IDistributionSourcePackage, |
12 | @@ -267,6 +266,7 @@ | |||
13 | 267 | from lp.registry.interfaces.productseries import IProductSeries | 266 | from lp.registry.interfaces.productseries import IProductSeries |
14 | 268 | from lp.registry.interfaces.projectgroup import IProjectGroup | 267 | from lp.registry.interfaces.projectgroup import IProjectGroup |
15 | 269 | from lp.registry.interfaces.sourcepackage import ISourcePackage | 268 | from lp.registry.interfaces.sourcepackage import ISourcePackage |
16 | 269 | from lp.registry.model.sourcepackage import SourcePackage | ||
17 | 270 | from lp.registry.vocabularies import MilestoneVocabulary | 270 | from lp.registry.vocabularies import MilestoneVocabulary |
18 | 271 | from lp.services.fields import PersonChoice | 271 | from lp.services.fields import PersonChoice |
19 | 272 | from lp.services.propertycache import cachedproperty | 272 | from lp.services.propertycache import cachedproperty |
20 | @@ -3152,32 +3152,45 @@ | |||
21 | 3152 | self.many_bugtasks = len(self.bugtasks) >= 10 | 3152 | self.many_bugtasks = len(self.bugtasks) >= 10 |
22 | 3153 | self.cached_milestone_source = CachedMilestoneSourceFactory() | 3153 | self.cached_milestone_source = CachedMilestoneSourceFactory() |
23 | 3154 | self.user_is_subscribed = self.context.isSubscribed(self.user) | 3154 | self.user_is_subscribed = self.context.isSubscribed(self.user) |
24 | 3155 | distro_packages = defaultdict(list) | ||
25 | 3156 | distro_series_packages = defaultdict(list) | 3155 | distro_series_packages = defaultdict(list) |
26 | 3157 | for bugtask in self.bugtasks: | 3156 | for bugtask in self.bugtasks: |
27 | 3158 | target = bugtask.target | 3157 | target = bugtask.target |
28 | 3159 | if IDistributionSourcePackage.providedBy(target): | 3158 | if IDistributionSourcePackage.providedBy(target): |
31 | 3160 | distro_packages[target.distribution].append( | 3159 | distro_series = target.distribution.currentseries |
32 | 3161 | target.sourcepackagename) | 3160 | if distro_series is not None: |
33 | 3161 | distro_series_packages[distro_series].append( | ||
34 | 3162 | target.sourcepackagename) | ||
35 | 3162 | if ISourcePackage.providedBy(target): | 3163 | if ISourcePackage.providedBy(target): |
36 | 3163 | distro_series_packages[target.distroseries].append( | 3164 | distro_series_packages[target.distroseries].append( |
37 | 3164 | target.sourcepackagename) | 3165 | target.sourcepackagename) |
38 | 3165 | distro_set = getUtility(IDistributionSet) | ||
39 | 3166 | self.target_releases = dict(distro_set.getCurrentSourceReleases( | ||
40 | 3167 | distro_packages)) | ||
41 | 3168 | distro_series_set = getUtility(IDistroSeriesSet) | 3166 | distro_series_set = getUtility(IDistroSeriesSet) |
44 | 3169 | self.target_releases.update( | 3167 | self.target_releases = distro_series_set.getCurrentSourceReleases( |
45 | 3170 | distro_series_set.getCurrentSourceReleases(distro_series_packages)) | 3168 | distro_series_packages) |
46 | 3169 | |||
47 | 3170 | def _get_target_release(self, target): | ||
48 | 3171 | """Get a target release for target.""" | ||
49 | 3172 | error = None | ||
50 | 3173 | if not (IDistributionSourcePackage.providedBy(target) or | ||
51 | 3174 | ISourcePackage.providedBy(target)): | ||
52 | 3175 | return None, None | ||
53 | 3176 | distribution = target.distribution | ||
54 | 3177 | if IDistributionSourcePackage.providedBy(target): | ||
55 | 3178 | target = SourcePackage(target.sourcepackagename, | ||
56 | 3179 | distribution.currentseries) | ||
57 | 3180 | if target.distroseries is not None: | ||
58 | 3181 | current_release = self.target_releases.get(target) | ||
59 | 3182 | else: | ||
60 | 3183 | current_release = None | ||
61 | 3184 | if current_release is None: | ||
62 | 3185 | error = "No current release for this source package in %s" % ( | ||
63 | 3186 | distribution.displayname) | ||
64 | 3187 | return current_release, error | ||
65 | 3171 | 3188 | ||
66 | 3172 | def getTargetLinkTitle(self, target): | 3189 | def getTargetLinkTitle(self, target): |
67 | 3173 | """Return text to put as the title for the link to the target.""" | 3190 | """Return text to put as the title for the link to the target.""" |
72 | 3174 | if not (IDistributionSourcePackage.providedBy(target) or | 3191 | current_release, result = self._get_target_release(target) |
69 | 3175 | ISourcePackage.providedBy(target)): | ||
70 | 3176 | return None | ||
71 | 3177 | current_release = self.target_releases.get(target) | ||
73 | 3178 | if current_release is None: | 3192 | if current_release is None: |
76 | 3179 | return "No current release for this source package in %s" % ( | 3193 | return result |
75 | 3180 | target.distribution.displayname) | ||
77 | 3181 | uploader = current_release.creator | 3194 | uploader = current_release.creator |
78 | 3182 | maintainer = current_release.maintainer | 3195 | maintainer = current_release.maintainer |
79 | 3183 | return ( | 3196 | return ( |
80 | 3184 | 3197 | ||
81 | === modified file 'lib/lp/bugs/browser/tests/bugtask-target-link-titles.txt' | |||
82 | --- lib/lp/bugs/browser/tests/bugtask-target-link-titles.txt 2010-08-22 18:31:30 +0000 | |||
83 | +++ lib/lp/bugs/browser/tests/bugtask-target-link-titles.txt 2011-03-02 05:19:17 +0000 | |||
84 | @@ -89,6 +89,8 @@ | |||
85 | 89 | >>> print view.getTargetLinkTitle(published_distro) | 89 | >>> print view.getTargetLinkTitle(published_distro) |
86 | 90 | None | 90 | None |
87 | 91 | >>> view = set_up_view(published_evolution) | 91 | >>> view = set_up_view(published_evolution) |
88 | 92 | >>> from lp.registry.interfaces.series import SeriesStatus | ||
89 | 93 | >>> published_distro.currentseries.status = SeriesStatus.FROZEN | ||
90 | 92 | >>> print view.getTargetLinkTitle(published_evolution) | 94 | >>> print view.getTargetLinkTitle(published_evolution) |
91 | 93 | Latest release: 1.0, uploaded to universe on 2008-07-18 09:30:15+00:00 | 95 | Latest release: 1.0, uploaded to universe on 2008-07-18 09:30:15+00:00 |
92 | 94 | by Foo Bar (name16), maintained by No Privileges Person (no-priv) | 96 | by Foo Bar (name16), maintained by No Privileges Person (no-priv) |
93 | @@ -192,7 +194,7 @@ | |||
94 | 192 | >>> view = BugTasksAndNominationsView(bug, None) | 194 | >>> view = BugTasksAndNominationsView(bug, None) |
95 | 193 | >>> view.initialize() | 195 | >>> view.initialize() |
96 | 194 | >>> for bug_target in bug_targets: | 196 | >>> for bug_target in bug_targets: |
98 | 195 | ... release = view.target_releases.get(bug_target) | 197 | ... release, _ = view._get_target_release(bug_target) |
99 | 196 | ... if release is None: | 198 | ... if release is None: |
100 | 197 | ... version = 'No releases' | 199 | ... version = 'No releases' |
101 | 198 | ... else: | 200 | ... else: |
102 | @@ -201,7 +203,7 @@ | |||
103 | 201 | product: No releases | 203 | product: No releases |
104 | 202 | product/product-series: No releases | 204 | product/product-series: No releases |
105 | 203 | published-distro: No releases | 205 | published-distro: No releases |
107 | 204 | evolution (Published Distro): 2.0 | 206 | evolution (Published Distro): 1.0 |
108 | 205 | Published-distro Published-distro-series: No releases | 207 | Published-distro Published-distro-series: No releases |
109 | 206 | evolution (Published-distro Published-distro-series): 1.0 | 208 | evolution (Published-distro Published-distro-series): 1.0 |
110 | 207 | unpublished-distro: No releases | 209 | unpublished-distro: No releases |
111 | 208 | 210 | ||
112 | === modified file 'lib/lp/bugs/stories/bugs/xx-bug-index.txt' | |||
113 | --- lib/lp/bugs/stories/bugs/xx-bug-index.txt 2010-05-19 05:47:50 +0000 | |||
114 | +++ lib/lp/bugs/stories/bugs/xx-bug-index.txt 2011-03-02 05:19:17 +0000 | |||
115 | @@ -61,11 +61,23 @@ | |||
116 | 61 | 1 | 61 | 1 |
117 | 62 | 62 | ||
118 | 63 | If the context is a distribution package, the package name has a | 63 | If the context is a distribution package, the package name has a |
120 | 64 | tooltip containing the package details. | 64 | tooltip containing the package details. The detailed tests for the tooltip |
121 | 65 | contents are in lib/lp/bugs/browser/tests/bugtask-target-link-titles.txt so we | ||
122 | 66 | just need to check that one is set - that the layers are wired together. | ||
123 | 67 | |||
124 | 68 | >>> from zope.component import getUtility | ||
125 | 69 | >>> from lp.registry.interfaces.distribution import IDistributionSet | ||
126 | 70 | >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu') | ||
127 | 71 | >>> mozilla = ubuntu.getSourcePackage('mozilla-firefox') | ||
128 | 72 | >>> mozilla_release = factory.makeSourcePackageRelease( | ||
129 | 73 | ... sourcepackagename=mozilla.sourcepackagename, | ||
130 | 74 | ... distroseries=mozilla.distribution.currentseries, | ||
131 | 75 | ... archive=mozilla.distribution.main_archive, version='0.9') | ||
132 | 76 | |||
133 | 65 | 77 | ||
134 | 66 | >>> print anon_browser.getLink('mozilla-firefox (Ubuntu)').attrs['title'] | 78 | >>> print anon_browser.getLink('mozilla-firefox (Ubuntu)').attrs['title'] |
137 | 67 | Latest release: 0.9, uploaded to main on 2004-09-27 11:57:13+00:00... | 79 | Latest release: 0.9, uploaded to main on ... |
138 | 68 | by Mark Shuttleworth (mark), maintained by Mark Shuttleworth (mark) | 80 | by ..., maintained by ... |
139 | 69 | 81 | ||
140 | 70 | >>> print anon_browser.getLink('mozilla-firefox (Debian)').attrs['title'] | 82 | >>> print anon_browser.getLink('mozilla-firefox (Debian)').attrs['title'] |
141 | 71 | No current release for this source package in Debian | 83 | No current release for this source package in Debian |
142 | 72 | 84 | ||
143 | === modified file 'lib/lp/registry/browser/product.py' | |||
144 | --- lib/lp/registry/browser/product.py 2011-02-05 06:11:48 +0000 | |||
145 | +++ lib/lp/registry/browser/product.py 2011-03-02 05:19:17 +0000 | |||
146 | @@ -2038,9 +2038,9 @@ | |||
147 | 2038 | # Set the source_package_release attribute on the licenses | 2038 | # Set the source_package_release attribute on the licenses |
148 | 2039 | # widget, so that the source package's copyright info can be | 2039 | # widget, so that the source package's copyright info can be |
149 | 2040 | # displayed. | 2040 | # displayed. |
151 | 2041 | ubuntu = getUtility(ILaunchpadCelebrities).ubuntu | 2041 | ubuntu_dev = getUtility(ILaunchpadCelebrities).ubuntu.currentseries |
152 | 2042 | if self.source_package_name is not None: | 2042 | if self.source_package_name is not None: |
154 | 2043 | release_list = ubuntu.getCurrentSourceReleases( | 2043 | release_list = ubuntu_dev.getCurrentSourceReleases( |
155 | 2044 | [self.source_package_name]) | 2044 | [self.source_package_name]) |
156 | 2045 | if len(release_list) != 0: | 2045 | if len(release_list) != 0: |
157 | 2046 | self.widgets['licenses'].source_package_release = ( | 2046 | self.widgets['licenses'].source_package_release = ( |
158 | 2047 | 2047 | ||
159 | === modified file 'lib/lp/registry/interfaces/distribution.py' | |||
160 | --- lib/lp/registry/interfaces/distribution.py 2011-02-24 15:30:54 +0000 | |||
161 | +++ lib/lp/registry/interfaces/distribution.py 2011-03-02 05:19:17 +0000 | |||
162 | @@ -417,16 +417,6 @@ | |||
163 | 417 | Receives a sourcepackagerelease. | 417 | Receives a sourcepackagerelease. |
164 | 418 | """ | 418 | """ |
165 | 419 | 419 | ||
166 | 420 | def getCurrentSourceReleases(source_package_names): | ||
167 | 421 | """Get the current release of a list of source packages. | ||
168 | 422 | |||
169 | 423 | :param source_package_names: a list of `ISourcePackageName` | ||
170 | 424 | instances. | ||
171 | 425 | |||
172 | 426 | :return: a dict where the key is a `IDistributionSourcePackage` | ||
173 | 427 | and the value is a `IDistributionSourcePackageRelease`. | ||
174 | 428 | """ | ||
175 | 429 | |||
176 | 430 | def getDistroSeriesAndPocket(distroseriesname): | 420 | def getDistroSeriesAndPocket(distroseriesname): |
177 | 431 | """Return a (distroseries,pocket) tuple which is the given textual | 421 | """Return a (distroseries,pocket) tuple which is the given textual |
178 | 432 | distroseriesname in this distribution.""" | 422 | distroseriesname in this distribution.""" |
179 | @@ -692,15 +682,6 @@ | |||
180 | 692 | members, owner, mugshot=None, logo=None, icon=None): | 682 | members, owner, mugshot=None, logo=None, icon=None): |
181 | 693 | """Create a new distribution.""" | 683 | """Create a new distribution.""" |
182 | 694 | 684 | ||
183 | 695 | def getCurrentSourceReleases(distro_to_source_packagenames): | ||
184 | 696 | """Lookup many distribution source package releases. | ||
185 | 697 | |||
186 | 698 | :param distro_to_source_packagenames: A dictionary with | ||
187 | 699 | its keys being `IDistribution` and its values a list of | ||
188 | 700 | `ISourcePackageName`. | ||
189 | 701 | :return: A dict as per `IDistribution.getCurrentSourceReleases` | ||
190 | 702 | """ | ||
191 | 703 | |||
192 | 704 | 685 | ||
193 | 705 | class NoSuchDistribution(NameLookupFailed): | 686 | class NoSuchDistribution(NameLookupFailed): |
194 | 706 | """Raised when we try to find a distribution that doesn't exist.""" | 687 | """Raised when we try to find a distribution that doesn't exist.""" |
195 | 707 | 688 | ||
196 | === modified file 'lib/lp/registry/model/distribution.py' | |||
197 | --- lib/lp/registry/model/distribution.py 2011-03-01 05:05:26 +0000 | |||
198 | +++ lib/lp/registry/model/distribution.py 2011-03-02 05:19:17 +0000 | |||
199 | @@ -775,11 +775,6 @@ | |||
200 | 775 | """See `IDistribution`.""" | 775 | """See `IDistribution`.""" |
201 | 776 | return DistributionSourcePackageRelease(self, sourcepackagerelease) | 776 | return DistributionSourcePackageRelease(self, sourcepackagerelease) |
202 | 777 | 777 | ||
203 | 778 | def getCurrentSourceReleases(self, source_package_names): | ||
204 | 779 | """See `IDistribution`.""" | ||
205 | 780 | return getUtility(IDistributionSet).getCurrentSourceReleases( | ||
206 | 781 | {self:source_package_names}) | ||
207 | 782 | |||
208 | 783 | @property | 778 | @property |
209 | 784 | def has_any_specifications(self): | 779 | def has_any_specifications(self): |
210 | 785 | """See `IHasSpecifications`.""" | 780 | """See `IHasSpecifications`.""" |
211 | @@ -1900,56 +1895,3 @@ | |||
212 | 1900 | getUtility(IArchiveSet).new(distribution=distro, | 1895 | getUtility(IArchiveSet).new(distribution=distro, |
213 | 1901 | owner=owner, purpose=ArchivePurpose.PRIMARY) | 1896 | owner=owner, purpose=ArchivePurpose.PRIMARY) |
214 | 1902 | return distro | 1897 | return distro |
215 | 1903 | |||
216 | 1904 | def getCurrentSourceReleases(self, distro_source_packagenames): | ||
217 | 1905 | """See `IDistributionSet`.""" | ||
218 | 1906 | # Builds one query for all the distro_source_packagenames. | ||
219 | 1907 | # This may need tuning: its possible that grouping by the common | ||
220 | 1908 | # archives may yield better efficiency: the current code is | ||
221 | 1909 | # just a direct push-down of the previous in-python lookup to SQL. | ||
222 | 1910 | series_clauses = [] | ||
223 | 1911 | distro_lookup = {} | ||
224 | 1912 | for distro, package_names in distro_source_packagenames.items(): | ||
225 | 1913 | source_package_ids = map(attrgetter('id'), package_names) | ||
226 | 1914 | # all_distro_archive_ids is just a list of ints, but it gets | ||
227 | 1915 | # wrapped anyway - and sqlvalues goes boom. | ||
228 | 1916 | archives = removeSecurityProxy( | ||
229 | 1917 | distro.all_distro_archive_ids) | ||
230 | 1918 | clause = """(spr.sourcepackagename IN %s AND | ||
231 | 1919 | spph.archive IN %s AND | ||
232 | 1920 | ds.distribution = %s) | ||
233 | 1921 | """ % sqlvalues(source_package_ids, archives, distro.id) | ||
234 | 1922 | series_clauses.append(clause) | ||
235 | 1923 | distro_lookup[distro.id] = distro | ||
236 | 1924 | if not len(series_clauses): | ||
237 | 1925 | return {} | ||
238 | 1926 | combined_clause = "(" + " OR ".join(series_clauses) + ")" | ||
239 | 1927 | |||
240 | 1928 | releases = IStore(SourcePackageRelease).find( | ||
241 | 1929 | (SourcePackageRelease, Distribution.id), SQL(""" | ||
242 | 1930 | (SourcePackageRelease.id, Distribution.id) IN ( | ||
243 | 1931 | SELECT DISTINCT ON ( | ||
244 | 1932 | spr.sourcepackagename, ds.distribution) | ||
245 | 1933 | spr.id, ds.distribution | ||
246 | 1934 | FROM | ||
247 | 1935 | SourcePackageRelease AS spr, | ||
248 | 1936 | SourcePackagePublishingHistory AS spph, | ||
249 | 1937 | DistroSeries AS ds | ||
250 | 1938 | WHERE | ||
251 | 1939 | spph.sourcepackagerelease = spr.id | ||
252 | 1940 | AND spph.distroseries = ds.id | ||
253 | 1941 | AND spph.status IN %s | ||
254 | 1942 | AND %s | ||
255 | 1943 | ORDER BY | ||
256 | 1944 | spr.sourcepackagename, ds.distribution, spph.id DESC | ||
257 | 1945 | ) | ||
258 | 1946 | """ | ||
259 | 1947 | % (sqlvalues(active_publishing_status) + (combined_clause,)))) | ||
260 | 1948 | result = {} | ||
261 | 1949 | for sp_release, distro_id in releases: | ||
262 | 1950 | distro = distro_lookup[distro_id] | ||
263 | 1951 | sourcepackage = distro.getSourcePackage( | ||
264 | 1952 | sp_release.sourcepackagename) | ||
265 | 1953 | result[sourcepackage] = DistributionSourcePackageRelease( | ||
266 | 1954 | distro, sp_release) | ||
267 | 1955 | return result | ||
268 | 1956 | 1898 | ||
269 | === modified file 'lib/lp/registry/model/distributionsourcepackage.py' | |||
270 | --- lib/lp/registry/model/distributionsourcepackage.py 2011-01-21 08:12:29 +0000 | |||
271 | +++ lib/lp/registry/model/distributionsourcepackage.py 2011-03-02 05:19:17 +0000 | |||
272 | @@ -298,9 +298,11 @@ | |||
273 | 298 | @property | 298 | @property |
274 | 299 | def currentrelease(self): | 299 | def currentrelease(self): |
275 | 300 | """See `IDistributionSourcePackage`.""" | 300 | """See `IDistributionSourcePackage`.""" |
277 | 301 | releases = self.distribution.getCurrentSourceReleases( | 301 | releases = self.distribution.currentseries.getCurrentSourceReleases( |
278 | 302 | [self.sourcepackagename]) | 302 | [self.sourcepackagename]) |
280 | 303 | return releases.get(self) | 303 | if releases: |
281 | 304 | return releases.values()[0] | ||
282 | 305 | return None | ||
283 | 304 | 306 | ||
284 | 305 | def bugtasks(self, quantity=None): | 307 | def bugtasks(self, quantity=None): |
285 | 306 | """See `IDistributionSourcePackage`.""" | 308 | """See `IDistributionSourcePackage`.""" |
286 | 307 | 309 | ||
287 | === modified file 'lib/lp/registry/tests/test_distribution.py' | |||
288 | --- lib/lp/registry/tests/test_distribution.py 2010-10-24 12:46:23 +0000 | |||
289 | +++ lib/lp/registry/tests/test_distribution.py 2011-03-02 05:19:17 +0000 | |||
290 | @@ -6,7 +6,6 @@ | |||
291 | 6 | __metaclass__ = type | 6 | __metaclass__ = type |
292 | 7 | 7 | ||
293 | 8 | from lazr.lifecycle.snapshot import Snapshot | 8 | from lazr.lifecycle.snapshot import Snapshot |
294 | 9 | from zope.security.proxy import removeSecurityProxy | ||
295 | 10 | 9 | ||
296 | 11 | from canonical.testing.layers import ( | 10 | from canonical.testing.layers import ( |
297 | 12 | DatabaseFunctionalLayer, | 11 | DatabaseFunctionalLayer, |
298 | @@ -15,13 +14,6 @@ | |||
299 | 15 | from lp.registry.errors import NoSuchDistroSeries | 14 | from lp.registry.errors import NoSuchDistroSeries |
300 | 16 | from lp.registry.interfaces.distribution import IDistribution | 15 | from lp.registry.interfaces.distribution import IDistribution |
301 | 17 | from lp.registry.interfaces.series import SeriesStatus | 16 | from lp.registry.interfaces.series import SeriesStatus |
302 | 18 | from lp.registry.tests.test_distroseries import ( | ||
303 | 19 | TestDistroSeriesCurrentSourceReleases, | ||
304 | 20 | ) | ||
305 | 21 | from lp.services.propertycache import get_property_cache | ||
306 | 22 | from lp.soyuz.interfaces.distributionsourcepackagerelease import ( | ||
307 | 23 | IDistributionSourcePackageRelease, | ||
308 | 24 | ) | ||
309 | 25 | from lp.testing import TestCaseWithFactory | 17 | from lp.testing import TestCaseWithFactory |
310 | 26 | 18 | ||
311 | 27 | 19 | ||
312 | @@ -48,64 +40,6 @@ | |||
313 | 48 | self.assertEqual("'\\u0170-distro'", displayname) | 40 | self.assertEqual("'\\u0170-distro'", displayname) |
314 | 49 | 41 | ||
315 | 50 | 42 | ||
316 | 51 | class TestDistributionCurrentSourceReleases( | ||
317 | 52 | TestDistroSeriesCurrentSourceReleases): | ||
318 | 53 | """Test for Distribution.getCurrentSourceReleases(). | ||
319 | 54 | |||
320 | 55 | This works in the same way as | ||
321 | 56 | DistroSeries.getCurrentSourceReleases() works, except that we look | ||
322 | 57 | for the latest published source across multiple distro series. | ||
323 | 58 | """ | ||
324 | 59 | |||
325 | 60 | layer = LaunchpadFunctionalLayer | ||
326 | 61 | release_interface = IDistributionSourcePackageRelease | ||
327 | 62 | |||
328 | 63 | @property | ||
329 | 64 | def test_target(self): | ||
330 | 65 | return self.distribution | ||
331 | 66 | |||
332 | 67 | def test_which_distroseries_does_not_matter(self): | ||
333 | 68 | # When checking for the current release, we only care about the | ||
334 | 69 | # version numbers. We don't care whether the version is | ||
335 | 70 | # published in a earlier or later series. | ||
336 | 71 | self.current_series = self.factory.makeDistroRelease( | ||
337 | 72 | self.distribution, '1.0', status=SeriesStatus.CURRENT) | ||
338 | 73 | self.publisher.getPubSource( | ||
339 | 74 | version='0.9', distroseries=self.current_series) | ||
340 | 75 | self.publisher.getPubSource( | ||
341 | 76 | version='1.0', distroseries=self.development_series) | ||
342 | 77 | self.assertCurrentVersion('1.0') | ||
343 | 78 | |||
344 | 79 | self.publisher.getPubSource( | ||
345 | 80 | version='1.1', distroseries=self.current_series) | ||
346 | 81 | self.assertCurrentVersion('1.1') | ||
347 | 82 | |||
348 | 83 | def test_distribution_series_cache(self): | ||
349 | 84 | distribution = removeSecurityProxy( | ||
350 | 85 | self.factory.makeDistribution('foo')) | ||
351 | 86 | |||
352 | 87 | cache = get_property_cache(distribution) | ||
353 | 88 | |||
354 | 89 | # Not yet cached. | ||
355 | 90 | self.assertNotIn("series", cache) | ||
356 | 91 | |||
357 | 92 | # Now cached. | ||
358 | 93 | series = distribution.series | ||
359 | 94 | self.assertIs(series, cache.series) | ||
360 | 95 | |||
361 | 96 | # Cache cleared. | ||
362 | 97 | distribution.newSeries( | ||
363 | 98 | name='bar', displayname='Bar', title='Bar', summary='', | ||
364 | 99 | description='', version='1', parent_series=None, | ||
365 | 100 | owner=self.factory.makePerson()) | ||
366 | 101 | self.assertNotIn("series", cache) | ||
367 | 102 | |||
368 | 103 | # New cached value. | ||
369 | 104 | series = distribution.series | ||
370 | 105 | self.assertEqual(1, len(series)) | ||
371 | 106 | self.assertIs(series, cache.series) | ||
372 | 107 | |||
373 | 108 | |||
374 | 109 | class SeriesByStatusTests(TestCaseWithFactory): | 43 | class SeriesByStatusTests(TestCaseWithFactory): |
375 | 110 | """Test IDistribution.getSeriesByStatus(). | 44 | """Test IDistribution.getSeriesByStatus(). |
376 | 111 | """ | 45 | """ |
377 | 112 | 46 | ||
378 | === modified file 'lib/lp/registry/tests/test_distroseries.py' | |||
379 | --- lib/lp/registry/tests/test_distroseries.py 2010-10-26 15:47:24 +0000 | |||
380 | +++ lib/lp/registry/tests/test_distroseries.py 2011-03-02 05:19:17 +0000 | |||
381 | @@ -152,13 +152,13 @@ | |||
382 | 152 | def test_get_multiple(self): | 152 | def test_get_multiple(self): |
383 | 153 | # getCurrentSourceReleases() allows you to get information about | 153 | # getCurrentSourceReleases() allows you to get information about |
384 | 154 | # the current release for multiple packages at the same time. | 154 | # the current release for multiple packages at the same time. |
387 | 155 | # This is done using a single DB query, making it more efficient | 155 | # This is done using a set queries, making it more efficient than |
388 | 156 | # than using IDistributionSource.currentrelease. | 156 | # looking up each package separately. |
389 | 157 | self.publisher.getPubSource(version='0.9', sourcename='foo') | 157 | self.publisher.getPubSource(version='0.9', sourcename='foo') |
390 | 158 | self.publisher.getPubSource(version='1.0', sourcename='bar') | 158 | self.publisher.getPubSource(version='1.0', sourcename='bar') |
394 | 159 | foo_package = self.distribution.getSourcePackage('foo') | 159 | foo_package = self.publisher.distroseries.getSourcePackage('foo') |
395 | 160 | bar_package = self.distribution.getSourcePackage('bar') | 160 | bar_package = self.publisher.distroseries.getSourcePackage('bar') |
396 | 161 | releases = self.distribution.getCurrentSourceReleases( | 161 | releases = self.publisher.distroseries.getCurrentSourceReleases( |
397 | 162 | [foo_package.sourcepackagename, bar_package.sourcepackagename]) | 162 | [foo_package.sourcepackagename, bar_package.sourcepackagename]) |
398 | 163 | self.assertEqual(releases[foo_package].version, '0.9') | 163 | self.assertEqual(releases[foo_package].version, '0.9') |
399 | 164 | self.assertEqual(releases[bar_package].version, '1.0') | 164 | self.assertEqual(releases[bar_package].version, '1.0') |
400 | 165 | 165 | ||
401 | === modified file 'lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt' | |||
402 | --- lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt 2010-11-01 15:46:48 +0000 | |||
403 | +++ lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt 2011-03-02 05:19:17 +0000 | |||
404 | @@ -209,7 +209,10 @@ | |||
405 | 209 | is "NEW". | 209 | is "NEW". |
406 | 210 | 210 | ||
407 | 211 | >>> cdrkit_ubuntu = ubuntu.getSourcePackage('cdrkit') | 211 | >>> cdrkit_ubuntu = ubuntu.getSourcePackage('cdrkit') |
409 | 212 | >>> cdrkit_release = cdrkit_ubuntu.currentrelease.sourcepackagerelease | 212 | >>> cdrkit_release = factory.makeSourcePackageRelease( |
410 | 213 | ... sourcepackagename=cdrkit_ubuntu.sourcepackagename, | ||
411 | 214 | ... distroseries=cdrkit_ubuntu.distribution['warty'], | ||
412 | 215 | ... archive=cdrkit_ubuntu.distribution.main_archive, version='1.0') | ||
413 | 213 | 216 | ||
414 | 214 | >>> cdrkit_bug_id = cdrkit_ubuntu.createBug(bug_params).id | 217 | >>> cdrkit_bug_id = cdrkit_ubuntu.createBug(bug_params).id |
415 | 215 | 218 | ||
416 | 216 | 219 | ||
417 | === modified file 'lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt' | |||
418 | --- lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt 2011-01-12 23:07:40 +0000 | |||
419 | +++ lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt 2011-03-02 05:19:17 +0000 | |||
420 | @@ -12,6 +12,7 @@ | |||
421 | 12 | >>> stp = SoyuzTestPublisher() | 12 | >>> stp = SoyuzTestPublisher() |
422 | 13 | >>> login('foo.bar@canonical.com') | 13 | >>> login('foo.bar@canonical.com') |
423 | 14 | >>> stp.prepareBreezyAutotest() | 14 | >>> stp.prepareBreezyAutotest() |
424 | 15 | >>> stp.distroseries = stp.ubuntutest.currentseries | ||
425 | 15 | >>> source = stp.getPubSource('testing-dspr', version='1.0') | 16 | >>> source = stp.getPubSource('testing-dspr', version='1.0') |
426 | 16 | >>> source.setPublished() | 17 | >>> source.setPublished() |
427 | 17 | >>> binaries = stp.getPubBinaries(pub_source=source) | 18 | >>> binaries = stp.getPubBinaries(pub_source=source) |
I don't like the DistributionSou rcePackage. currentrelease change, but it's probably cleaner than the alternative. Otherwise this is fine.