Merge lp:~thumper/launchpad/short-lp-name-for-private-branches into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 11516
Proposed branch: lp:~thumper/launchpad/short-lp-name-for-private-branches
Merge into: lp:launchpad
Prerequisite: lp:~thumper/launchpad/xmlrpc-lp-name-resolution
Diff against target: 288 lines (+18/-146)
6 files modified
lib/lp/code/doc/branch-xmlrpc.txt (+1/-117)
lib/lp/code/interfaces/branch.py (+1/-3)
lib/lp/code/model/tests/test_branch.py (+10/-20)
lib/lp/code/stories/branches/xx-private-branch-listings.txt (+2/-2)
lib/lp/code/tests/test_branch.py (+2/-2)
lib/lp/registry/stories/product/xx-product-development-focus.txt (+2/-2)
To merge this branch: bzr merge lp:~thumper/launchpad/short-lp-name-for-private-branches
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+34509@code.launchpad.net

Commit message

Use short lp: alias names for projects with private trunks.

Description of the change

This branch is the final part of providing short lp name for private
branches that are linked to official series.

There is a little drive by clean up in the tests for imports and
removing unneeded syncUpdate calls.

I think we have got all the test failures here.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

All looks fine. I like the way you fixed the doctest :-)

Cheers,
mwh

Revision history for this message
Michael Hudson-Doyle (mwhudson) :
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/doc/branch-xmlrpc.txt'
2--- lib/lp/code/doc/branch-xmlrpc.txt 2010-02-19 03:06:12 +0000
3+++ lib/lp/code/doc/branch-xmlrpc.txt 2010-09-03 11:26:07 +0000
4@@ -338,120 +338,4 @@
5 The URLs that are likely to be faster or provide write access appear
6 earlier in the list.
7
8-
9-lp:project
10-==========
11-
12-If you specify a path with a single segment, then Launchpad treats that
13-path as the name of a project, and returns URLs to the branch
14-associated with the project's development focus series.
15-
16- >>> results = branchset_api.resolve_lp_path('evolution')
17- >>> for url in results['urls']:
18- ... print url
19- bzr+ssh://bazaar.launchpad.dev/~vcs-imports/evolution/main
20- http://bazaar.launchpad.dev/~vcs-imports/evolution/main
21-
22-
23-Launchpad returns a fault if the development focus doesn't have branch
24-associated with it.
25-
26- >>> branchset_api.resolve_lp_path('firefox')
27- Traceback (most recent call last):
28- ...
29- Fault: <Fault 170: 'Mozilla Firefox has no default branch.'>
30-
31-
32-Launchpad also returns a fault if the project doesn't exist.
33-
34- >>> branchset_api.resolve_lp_path('doesntexist')
35- Traceback (most recent call last):
36- ...
37- Fault: <Fault 10: 'No such project: doesntexist'>
38-
39-
40-lp:project/series
41-=================
42-
43-If you specify a path with two segments, Launchpad treats that as a
44-reference to a particular series on a project.
45-
46- >>> results = branchset_api.resolve_lp_path('evolution/trunk')
47- >>> for url in results['urls']:
48- ... print url
49- bzr+ssh://bazaar.launchpad.dev/~vcs-imports/evolution/main
50- http://bazaar.launchpad.dev/~vcs-imports/evolution/main
51-
52-
53-If the series doesn't exist, then the server returns a fault.
54-
55- >>> branchset_api.resolve_lp_path('firefox/doesntexist')
56- Traceback (most recent call last):
57- ...
58- Fault: <Fault 180: 'Project firefox has no series called "doesntexist"'>
59-
60-
61-Similarly if the project doesn't exist:
62-
63- >>> branchset_api.resolve_lp_path('doesntexist/trunk')
64- Traceback (most recent call last):
65- ...
66- Fault: <Fault 10: 'No such project: doesntexist'>
67-
68-
69-lp:~owner/product/branch
70-========================
71-
72-Anything longer than two segments is treated as a unique branch name
73-followed by an arbitrary path:
74-
75- >>> results = branchset_api.resolve_lp_path('~vcs-imports/evolution/main')
76- >>> for url in results['urls']:
77- ... print url
78- bzr+ssh://bazaar.launchpad.dev/~vcs-imports/evolution/main
79- http://bazaar.launchpad.dev/~vcs-imports/evolution/main
80-
81-
82-Launchpad will still resolve the branch even if it doesn't exist:
83-
84- >>> results = branchset_api.resolve_lp_path('~mark/+junk/doesntexist')
85- >>> for url in results['urls']:
86- ... print url
87- bzr+ssh://bazaar.launchpad.dev/~mark/%2Bjunk/doesntexist
88- http://bazaar.launchpad.dev/~mark/%2Bjunk/doesntexist
89-
90-
91-But if the project or the user doesn't exist, Launchpad will return a fault:
92-
93- >>> branchset_api.resolve_lp_path('~doesntexist/+junk/trunk')
94- Traceback (most recent call last):
95- ...
96- Fault: <Fault 200: 'No such person or team: doesntexist'>
97-
98- >>> branchset_api.resolve_lp_path('~mark/doesntexist/trunk')
99- Traceback (most recent call last):
100- ...
101- Fault: <Fault 10: 'No such project: doesntexist'>
102-
103-
104-Remote branches
105-===============
106-
107-Some branches on Launchpad are 'remote' branches. These branches are
108-not hosted on Launchpad and are only available (if at all) on remote
109-sites. For these branches, resolve_lp_path returns only a single URL.
110-
111- >>> from lp.code.enums import BranchType
112- >>> from lp.registry.interfaces.person import IPersonSet
113- >>> arbitrary_person = getUtility(IPersonSet).getByName('name12')
114- >>> from lp.code.interfaces.branchnamespace import (
115- ... get_branch_namespace)
116- >>> namespace = get_branch_namespace(arbitrary_person)
117- >>> namespace.createBranch(
118- ... branch_type=BranchType.REMOTE, name='remote',
119- ... registrant=arbitrary_person,
120- ... url='http://example.com/remote_branch')
121- <Branch u'~name12/+junk/remote' (...)>
122- >>> results = branchset_api.resolve_lp_path('~name12/+junk/remote')
123- >>> results['urls']
124- ['http://example.com/remote_branch']
125+For more tests see `lp.code.xmlrpc.tests.test_branch.py`.
126
127=== modified file 'lib/lp/code/interfaces/branch.py'
128--- lib/lp/code/interfaces/branch.py 2010-08-27 02:11:36 +0000
129+++ lib/lp/code/interfaces/branch.py 2010-09-03 11:26:07 +0000
130@@ -1303,9 +1303,7 @@
131 def branchIdentities(self):
132 """See `IBranch`."""
133 lp_prefix = config.codehosting.bzr_lp_prefix
134- if self.private or not self.target.supports_short_identites:
135- # XXX: thumper 2010-04-08, bug 261609
136- # We have to get around to fixing this
137+ if not self.target.supports_short_identites:
138 identities = []
139 else:
140 identities = [
141
142=== modified file 'lib/lp/code/model/tests/test_branch.py'
143--- lib/lp/code/model/tests/test_branch.py 2010-08-20 20:31:18 +0000
144+++ lib/lp/code/model/tests/test_branch.py 2010-09-03 11:26:07 +0000
145@@ -28,13 +28,6 @@
146 from canonical.config import config
147 from canonical.database.constants import UTC_NOW
148 from canonical.launchpad import _
149-from canonical.launchpad.ftests import (
150- ANONYMOUS,
151- login,
152- login_person,
153- logout,
154- syncUpdate,
155- )
156 from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
157 from canonical.launchpad.webapp.interfaces import IOpenLaunchBag
158 from canonical.testing import (
159@@ -120,6 +113,11 @@
160 from lp.registry.model.sourcepackage import SourcePackage
161 from lp.services.osutils import override_environ
162 from lp.testing import (
163+ ANONYMOUS,
164+ celebrity_logged_in,
165+ login,
166+ login_person,
167+ logout,
168 person_logged_in,
169 run_with_login,
170 TestCase,
171@@ -904,16 +902,12 @@
172 self.assertBzrIdentity(branch, linked_branch.bzr_path)
173
174 def test_private_linked_to_product(self):
175- # If a branch is private, then the bzr identity is the unique name,
176- # even if it's linked to a product. Of course, you have to be able to
177- # see the branch at all.
178+ # Private branches also have a short lp:url.
179 branch = self.factory.makeProductBranch(private=True)
180- owner = removeSecurityProxy(branch).owner
181- login_person(owner)
182- self.addCleanup(logout)
183- product = removeSecurityProxy(branch.product)
184- ICanHasLinkedBranch(product).setBranch(branch)
185- self.assertBzrIdentity(branch, branch.unique_name)
186+ with celebrity_logged_in('admin'):
187+ product = branch.product
188+ ICanHasLinkedBranch(product).setBranch(branch)
189+ self.assertBzrIdentity(branch, product.name)
190
191 def test_linked_to_series_and_dev_focus(self):
192 # If a branch is the development focus branch for a product and the
193@@ -1048,7 +1042,6 @@
194 deleted.
195 """
196 self.product.development_focus.branch = self.branch
197- syncUpdate(self.product.development_focus)
198 self.assertEqual(self.branch.canBeDeleted(), False,
199 "A branch that is a user branch for a product series"
200 " is not deletable.")
201@@ -1056,7 +1049,6 @@
202
203 def test_productSeriesTranslationsBranchDisablesDeletion(self):
204 self.product.development_focus.translations_branch = self.branch
205- syncUpdate(self.product.development_focus)
206 self.assertEqual(self.branch.canBeDeleted(), False,
207 "A branch that is a translations branch for a "
208 "product series is not deletable.")
209@@ -1219,7 +1211,6 @@
210 # Disable this merge proposal, to allow creating a new identical one
211 lp_admins = getUtility(ILaunchpadCelebrities).admin
212 merge_proposal1.rejectBranch(lp_admins, 'null:')
213- syncUpdate(merge_proposal1)
214 merge_proposal2 = self.branch.addLandingTarget(
215 self.branch.owner, target_branch, prerequisite_branch)
216 return merge_proposal1, merge_proposal2
217@@ -1603,7 +1594,6 @@
218 proposal = self.source.addLandingTarget(
219 self.user, self.target, self.prerequisite)
220 proposal.rejectBranch(self.user, 'some_revision')
221- syncUpdate(proposal)
222 self.source.addLandingTarget(
223 self.user, self.target, self.prerequisite)
224
225
226=== modified file 'lib/lp/code/stories/branches/xx-private-branch-listings.txt'
227--- lib/lp/code/stories/branches/xx-private-branch-listings.txt 2009-11-17 09:08:17 +0000
228+++ lib/lp/code/stories/branches/xx-private-branch-listings.txt 2010-09-03 11:26:07 +0000
229@@ -244,14 +244,14 @@
230
231 >>> print extract_text(
232 ... find_tag_by_id(admin_browser.contents, 'branch-details'))
233- lp://dev/~landscape-developers/landscape/trunk - Landscape Developers ...
234+ lp://dev/landscape - Landscape Developers ...
235
236 Landscape developers can see it.
237
238 >>> landscape_dev_browser.open('http://launchpad.dev/landscape/trunk')
239 >>> print extract_text(find_tag_by_id(
240 ... landscape_dev_browser.contents, 'branch-details'))
241- lp://dev/~landscape-developers/landscape/trunk - Landscape Developers ...
242+ lp://dev/landscape - Landscape Developers ...
243
244 But normal people can't.
245
246
247=== modified file 'lib/lp/code/tests/test_branch.py'
248--- lib/lp/code/tests/test_branch.py 2010-08-20 20:31:18 +0000
249+++ lib/lp/code/tests/test_branch.py 2010-09-03 11:26:07 +0000
250@@ -16,8 +16,8 @@
251 BranchSubscriptionNotificationLevel,
252 CodeReviewNotificationLevel,
253 )
254+from lp.code.interfaces.codehosting import SUPPORTED_SCHEMES
255 from lp.code.tests.helpers import make_official_package_branch
256-from lp.code.xmlrpc.branch import PublicCodehostingAPI
257 from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
258 from lp.testing import (
259 run_with_login,
260@@ -347,7 +347,7 @@
261
262 url_pattern = '%%s://bazaar.launchpad.dev/~%s/%s/%s' % (
263 branch.owner.name, branch.product.name, branch.name)
264- for scheme in PublicCodehostingAPI.supported_schemes:
265+ for scheme in SUPPORTED_SCHEMES:
266 public_url = branch.composePublicURL(scheme)
267 self.assertEqual(url_pattern % scheme, public_url)
268
269
270=== modified file 'lib/lp/registry/stories/product/xx-product-development-focus.txt'
271--- lib/lp/registry/stories/product/xx-product-development-focus.txt 2010-08-02 20:25:10 +0000
272+++ lib/lp/registry/stories/product/xx-product-development-focus.txt 2010-09-03 11:26:07 +0000
273@@ -161,13 +161,13 @@
274 >>> print_development_focus(owner_browser)
275 Development focus:
276 trunk series Change details
277- lp://dev/~eric/fooix/trunk Change branch
278+ lp://dev/fooix Change branch
279 View the branch content
280 Links:
281 trunk series (/fooix/trunk)
282 <span class="invisible-link">Change details</span>
283 (http://launchpad.dev/fooix/+edit)
284- lp://dev/~eric/fooix/trunk (http://code.launchpad.dev/~eric/fooix/trunk)
285+ lp://dev/fooix (http://code.launchpad.dev/~eric/fooix/trunk)
286 <span class="invisible-link">Change branch</span>
287 Change the branch for this series
288 (http://launchpad.dev/fooix/trunk/+linkbranch)