Merge lp:~jml/launchpad/remove-product-branch-portlet into lp:launchpad/db-devel

Proposed by Jonathan Lange
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 9524
Proposed branch: lp:~jml/launchpad/remove-product-branch-portlet
Merge into: lp:launchpad/db-devel
Diff against target: 218 lines (+0/-125)
8 files modified
lib/lp/code/browser/configure.zcml (+0/-11)
lib/lp/code/interfaces/branch.py (+0/-17)
lib/lp/code/model/branch.py (+0/-12)
lib/lp/code/model/tests/test_branchset.py (+0/-43)
lib/lp/code/templates/product-portlet-latestbranches.pt (+0/-30)
lib/lp/registry/browser/product.py (+0/-3)
lib/lp/registry/interfaces/product.py (+0/-3)
lib/lp/registry/model/product.py (+0/-6)
To merge this branch: bzr merge lp:~jml/launchpad/remove-product-branch-portlet
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+29532@code.launchpad.net

Commit message

Remove unused branch portlet and code that existed solely to support it.

Description of the change

I was poking around trying to delete the branch-related sample data across Launchpad and came across the getLatestBranchesForProduct method and its kin in IProduct.

AFAICT, it's only used in this one portlet, and I can't find this portlet actually being used anywhere on Launchpad. Maybe I'm looking in the wrong way. In any case, the tests are running now.

Merging against db-devel since that's where I made the branch. It can apply to devel once db-stable has been merged back in.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/configure.zcml'
2--- lib/lp/code/browser/configure.zcml 2010-06-03 23:33:00 +0000
3+++ lib/lp/code/browser/configure.zcml 2010-07-09 10:29:07 +0000
4@@ -863,17 +863,6 @@
5 permission="zope.Public"/>
6 </facet>
7
8- <browser:pages
9- for="lp.registry.interfaces.product.IProduct"
10- permission="zope.Public"
11- class="lp.registry.browser.product.ProductView">
12-
13- <browser:page
14- name="+portlet-latestbranches"
15- template="../templates/product-portlet-latestbranches.pt"/>
16-
17- </browser:pages>
18-
19 <browser:page
20 for="lp.registry.interfaces.product.IProduct"
21 class="lp.code.browser.branchlisting.ProductBranchesView"
22
23=== modified file 'lib/lp/code/interfaces/branch.py'
24--- lib/lp/code/interfaces/branch.py 2010-06-10 07:55:54 +0000
25+++ lib/lp/code/interfaces/branch.py 2010-07-09 10:29:07 +0000
26@@ -1236,23 +1236,6 @@
27 :type visible_by_user: `IPerson` or None
28 """
29
30- def getLatestBranchesForProduct(product, quantity, visible_by_user=None):
31- """Return the most recently created branches for the product.
32-
33- At most `quantity` branches are returned. Branches that have been
34- merged or abandoned don't appear in the results -- only branches that
35- match `DEFAULT_BRANCH_STATUS_IN_LISTING`.
36-
37- :param visible_by_user: If a person is not supplied, only public
38- branches are returned. If a person is supplied both public
39- branches, and the private branches that the person is entitled to
40- see are returned. Private branches are only visible to the owner
41- and subscribers of the branch, and to LP admins.
42- :type visible_by_user: `IPerson` or None
43- """
44- # XXX: JonathanLange 2008-11-27 spec=package-branches: This API needs
45- # to change for source package branches.
46-
47 @operation_parameters(
48 unique_name=TextLine(title=_('Branch unique name'), required=True))
49 @operation_returns_entry(IBranch)
50
51=== modified file 'lib/lp/code/model/branch.py'
52--- lib/lp/code/model/branch.py 2010-06-11 03:36:15 +0000
53+++ lib/lp/code/model/branch.py 2010-07-09 10:29:07 +0000
54@@ -1226,18 +1226,6 @@
55 branches.config(limit=branch_count)
56 return branches
57
58- def getLatestBranchesForProduct(self, product, quantity,
59- visible_by_user=None):
60- """See `IBranchSet`."""
61- assert product is not None, "Must have a valid product."
62- all_branches = getUtility(IAllBranches)
63- latest = all_branches.visibleByUser(visible_by_user).inProduct(
64- product).withLifecycleStatus(*DEFAULT_BRANCH_STATUS_IN_LISTING)
65- latest_branches = latest.getBranches().order_by(
66- Desc(Branch.date_created), Desc(Branch.id))
67- latest_branches.config(limit=quantity)
68- return latest_branches
69-
70 def getByUniqueName(self, unique_name):
71 """See `IBranchSet`."""
72 return getUtility(IBranchLookup).getByUniqueName(unique_name)
73
74=== modified file 'lib/lp/code/model/tests/test_branchset.py'
75--- lib/lp/code/model/tests/test_branchset.py 2009-11-19 15:30:47 +0000
76+++ lib/lp/code/model/tests/test_branchset.py 2010-07-09 10:29:07 +0000
77@@ -8,14 +8,9 @@
78 from unittest import TestLoader
79
80 from lp.code.model.branch import BranchSet
81-from lp.code.enums import BranchLifecycleStatus
82-from lp.registry.interfaces.product import IProductSet
83 from lp.testing import TestCaseWithFactory
84 from canonical.testing import DatabaseFunctionalLayer
85
86-from zope.component import getUtility
87-from zope.security.proxy import removeSecurityProxy
88-
89
90 class TestBranchSet(TestCaseWithFactory):
91
92@@ -23,46 +18,8 @@
93
94 def setUp(self):
95 TestCaseWithFactory.setUp(self)
96- self.product = getUtility(IProductSet).getByName('firefox')
97 self.branch_set = BranchSet()
98
99- def test_limitedByQuantity(self):
100- """When getting the latest branches for a product, we can specify the
101- maximum number of branches we want to know about.
102- """
103- quantity = 3
104- latest_branches = self.branch_set.getLatestBranchesForProduct(
105- self.product, quantity)
106- self.assertEqual(quantity, len(list(latest_branches)))
107-
108- def test_onlyForProduct(self):
109- """getLatestBranchesForProduct returns branches only from the
110- requested product.
111- """
112- quantity = 5
113- latest_branches = self.branch_set.getLatestBranchesForProduct(
114- self.product, quantity)
115- self.assertEqual(
116- [self.product.name] * quantity,
117- [branch.product.name for branch in latest_branches])
118-
119- def test_abandonedBranchesNotIncluded(self):
120- """getLatestBranchesForProduct does not include branches that have
121- been abandoned, because they are not relevant for those interested
122- in recent activity.
123- """
124- original_branches = list(
125- self.branch_set.getLatestBranchesForProduct(self.product, 5))
126- branch = original_branches[0]
127- # XXX: JonathanLange 2007-07-06: WHITEBOXING. The anonymous user
128- # cannot change branch details, so we remove the security proxy and
129- # change it.
130- branch = removeSecurityProxy(branch)
131- branch.lifecycle_status = BranchLifecycleStatus.ABANDONED
132- latest_branches = list(
133- self.branch_set.getLatestBranchesForProduct(self.product, 5))
134- self.assertEqual(original_branches[1:], latest_branches)
135-
136 def test_getByUrls(self):
137 # getByUrls returns a list of branches matching the list of URLs that
138 # it's given.
139
140=== removed file 'lib/lp/code/templates/product-portlet-latestbranches.pt'
141--- lib/lp/code/templates/product-portlet-latestbranches.pt 2009-07-17 17:59:07 +0000
142+++ lib/lp/code/templates/product-portlet-latestbranches.pt 1970-01-01 00:00:00 +0000
143@@ -1,30 +0,0 @@
144-<tal:root
145- xmlns:tal="http://xml.zope.org/namespaces/tal"
146- xmlns:metal="http://xml.zope.org/namespaces/metal"
147- xmlns:i18n="http://xml.zope.org/namespaces/i18n"
148- omit-tag="">
149-
150-<div
151- tal:condition="view/getLatestBranches"
152- class="portlet"
153- id="portlet-latest-branches"
154->
155- <h2>Latest branches</h2>
156- <div class="portletBody portletContent">
157- <ul class="branch">
158-
159- <li tal:repeat="branch view/getLatestBranches" class="branch">
160- <a tal:attributes="href branch/fmt:url"
161- tal:content="branch/name"
162- >branch name</a
163- ><img src="/@@/private" alt=" (private)"
164- tal:condition="branch/private"/>:
165- <a tal:replace="structure branch/owner/fmt:link">
166- Guilherme Salgado
167- </a>
168- </li>
169- </ul>
170-
171- </div>
172-</div>
173-</tal:root>
174
175=== modified file 'lib/lp/registry/browser/product.py'
176--- lib/lp/registry/browser/product.py 2010-06-23 18:41:02 +0000
177+++ lib/lp/registry/browser/product.py 2010-07-09 10:29:07 +0000
178@@ -965,9 +965,6 @@
179 url = canonical_url(series) + '/+bugs'
180 return get_buglisting_search_filter_url(url, status=status)
181
182- def getLatestBranches(self):
183- return self.context.getLatestBranches(visible_by_user=self.user)
184-
185 @property
186 def requires_commercial_subscription(self):
187 """Whether to display notice to purchase a commercial subscription."""
188
189=== modified file 'lib/lp/registry/interfaces/product.py'
190--- lib/lp/registry/interfaces/product.py 2010-06-14 20:15:22 +0000
191+++ lib/lp/registry/interfaces/product.py 2010-07-09 10:29:07 +0000
192@@ -685,9 +685,6 @@
193 :return: None
194 """
195
196- def getLatestBranches(quantity=5):
197- """Latest <quantity> branches registered for this product."""
198-
199 def getPackage(distroseries):
200 """Return a package in that distroseries for this product."""
201
202
203=== modified file 'lib/lp/registry/model/product.py'
204--- lib/lp/registry/model/product.py 2010-05-24 13:54:12 +0000
205+++ lib/lp/registry/model/product.py 2010-07-09 10:29:07 +0000
206@@ -658,12 +658,6 @@
207 """See `IBugTarget`."""
208 return self.name
209
210- def getLatestBranches(self, quantity=5, visible_by_user=None):
211- """See `IProduct`."""
212- return shortlist(
213- getUtility(IBranchSet).getLatestBranchesForProduct(
214- self, quantity, visible_by_user))
215-
216 def getPackage(self, distroseries):
217 """See `IProduct`."""
218 if isinstance(distroseries, Distribution):

Subscribers

People subscribed via source and target branches

to status/vote changes: