Merge lp:~mwhudson/launchpad/no-hosted-area-one-codehosting-endpoint into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 10828
Proposed branch: lp:~mwhudson/launchpad/no-hosted-area-one-codehosting-endpoint
Merge into: lp:launchpad
Prerequisite: lp:~mwhudson/launchpad/no-hosted-area-puller
Diff against target: 2294 lines (+436/-531)
28 files modified
bzrplugins/lpserve.py (+4/-4)
configs/development/launchpad-lazr.conf (+1/-2)
cronscripts/supermirror-pull.py (+1/-1)
lib/canonical/config/schema-lazr.conf (+7/-9)
lib/canonical/launchpad/interfaces/launchpad.py (+1/-3)
lib/canonical/launchpad/systemhomes.py (+6/-14)
lib/canonical/launchpad/xmlrpc/application.py (+4/-10)
lib/canonical/launchpad/xmlrpc/configure.zcml (+9/-22)
lib/lp/code/doc/xmlrpc-branch-filesystem.txt (+0/-31)
lib/lp/code/doc/xmlrpc-branch-puller.txt (+0/-31)
lib/lp/code/doc/xmlrpc-codehosting.txt (+32/-0)
lib/lp/code/interfaces/codehosting.py (+10/-23)
lib/lp/code/xmlrpc/codehosting.py (+58/-64)
lib/lp/code/xmlrpc/tests/test_codehosting.py (+174/-184)
lib/lp/codehosting/inmemory.py (+15/-29)
lib/lp/codehosting/puller/scheduler.py (+9/-9)
lib/lp/codehosting/puller/tests/test_scheduler.py (+7/-6)
lib/lp/codehosting/sftp.py (+2/-1)
lib/lp/codehosting/sshserver/daemon.py (+11/-11)
lib/lp/codehosting/tests/test_acceptance.py (+3/-2)
lib/lp/codehosting/tests/test_sftp.py (+3/-3)
lib/lp/codehosting/vfs/branchfs.py (+40/-36)
lib/lp/codehosting/vfs/branchfsclient.py (+17/-14)
lib/lp/codehosting/vfs/tests/test_branchfs.py (+18/-18)
lib/lp/codehosting/vfs/tests/test_branchfsclient.py (+1/-1)
lib/lp/codehosting/vfs/tests/test_filesystem.py (+1/-1)
lib/lp/codehosting/vfs/tests/test_transport.py (+1/-1)
scripts/update-stacked-on.py (+1/-1)
To merge this branch: bzr merge lp:~mwhudson/launchpad/no-hosted-area-one-codehosting-endpoint
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+23730@code.launchpad.net

Description of the change

Hi yet again Tim,

This large and EXTREMELY BORING branch combines the two codehosting api endpoints we currently have -- IBranchPuller and IBranchFileSystem -- into one -- ICodehostingAPI -- so that the puller can call the branchChanged method that is currently on IBranchPuller.

Cheers,
mwh

PS: it's very boring.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

The xmlrpc-codehosting.txt file has the heading "The BranchPuller application".

Perhaps we could rename the 'self.storage' to 'self.codehosting' in the
CodehostingTest, or 'self.codehosting_api' to be even move verbose.
M-% FTW

lib/lp/codehosting/sshserver/daemon.py
 - still mentions the authserver :-)

Apart from that, your were right, it is a boring branch, but good to go some renames.

review: Approve
Revision history for this message
Jonathan Lange (jml) wrote :

There is still an XML-RPC interface called IAuthServer. It's not a great name, but it's not a terrible name either.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

It's not too terrible a name for the endpoint that implements authentication. It's a bit silly for all the other ones :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrplugins/lpserve.py'
2--- bzrplugins/lpserve.py 2010-04-27 02:11:16 +0000
3+++ bzrplugins/lpserve.py 2010-04-27 02:11:35 +0000
4@@ -45,9 +45,9 @@
5 Option('mirror-directory',
6 help='serve branches from this directory. Defaults to '
7 'config.codehosting.mirrored_branches_root.'),
8- Option('branchfs-endpoint',
9+ Option('codehosting-endpoint',
10 help='the url of the internal XML-RPC server. Defaults to '
11- 'config.codehosting.branchfs_endpoint.',
12+ 'config.codehosting.codehosting_endpoint.',
13 type=unicode),
14 ]
15
16@@ -86,7 +86,7 @@
17 ui.ui_factory = old_factory
18
19 def run(self, user_id, port=None, branch_directory=None,
20- branchfs_endpoint_url=None, inet=False):
21+ codehosting_endpoint_url=None, inet=False):
22 from lp.codehosting.bzrutils import install_oops_handler
23 from lp.codehosting.vfs import get_lp_server, hooks
24 install_oops_handler(user_id)
25@@ -94,7 +94,7 @@
26 resource.setrlimit(resource.RLIMIT_AS, (four_gig, four_gig))
27 seen_new_branch = hooks.SetProcTitleHook()
28 lp_server = get_lp_server(
29- int(user_id), branchfs_endpoint_url, branch_directory,
30+ int(user_id), codehosting_endpoint_url, branch_directory,
31 seen_new_branch.seen)
32 lp_server.start_server()
33
34
35=== modified file 'configs/development/launchpad-lazr.conf'
36--- configs/development/launchpad-lazr.conf 2010-04-27 02:11:16 +0000
37+++ configs/development/launchpad-lazr.conf 2010-04-27 02:11:35 +0000
38@@ -52,8 +52,7 @@
39 [codehosting]
40 launch: True
41 authentication_endpoint: http://xmlrpc-private.launchpad.dev:8087/authserver
42-branchfs_endpoint: http://xmlrpc-private.launchpad.dev:8087/branchfilesystem
43-branch_puller_endpoint: http://xmlrpc-private.launchpad.dev:8087/branch_puller
44+codehosting_endpoint: http://xmlrpc-private.launchpad.dev:8087/codehosting
45 supermirror_root: http://bazaar.launchpad.dev/
46 hosted_branches_root: /var/tmp/bazaar.launchpad.dev/push-branches/
47 codebrowse_root: http://bazaar.launchpad.dev/
48
49=== modified file 'cronscripts/supermirror-pull.py'
50--- cronscripts/supermirror-pull.py 2010-03-25 18:06:39 +0000
51+++ cronscripts/supermirror-pull.py 2010-04-27 02:11:35 +0000
52@@ -44,7 +44,7 @@
53 parser.error("Unhandled arguments %s" % repr(arguments))
54 log = set_up_logging_for_script(options, 'supermirror_puller')
55 manager = scheduler.JobScheduler(
56- LoggingProxy(config.codehosting.branch_puller_endpoint, log), log,
57+ LoggingProxy(config.codehosting.codehosting_endpoint, log), log,
58 options.branch_type)
59
60 reactor.callWhenRunning(run_mirror, log, manager)
61
62=== modified file 'lib/canonical/config/schema-lazr.conf'
63--- lib/canonical/config/schema-lazr.conf 2010-04-27 02:11:16 +0000
64+++ lib/canonical/config/schema-lazr.conf 2010-04-27 02:11:35 +0000
65@@ -289,19 +289,17 @@
66 # datatype: string
67 authentication_endpoint: none
68
69-# The URL of the XML-RPC endpoint used to provide the data that drives the
70-# virtual file systems used by the code hosting service. This should
71-# implement IBranchFileSystem.
72-#
73-# datatype: string
74+# Obsolete.
75 branchfs_endpoint: none
76
77-# The URL of the XML-RPC endpoint that provides the interface from the
78-# puller to the rest of Launchpad. This should implement IPullerAPI.
79-#
80-# datatype: string
81+# Obsolete.
82 branch_puller_endpoint: none
83
84+# The URL of the XML-RPC endpoint that implements ICodehostingAPI.
85+#
86+# datatype: string
87+codehosting_endpoint: none
88+
89 # See [error_reports].
90 oops_prefix: none
91
92
93=== added directory 'lib/canonical/launchpad/apidoc'
94=== modified file 'lib/canonical/launchpad/interfaces/launchpad.py'
95--- lib/canonical/launchpad/interfaces/launchpad.py 2010-04-19 14:47:49 +0000
96+++ lib/canonical/launchpad/interfaces/launchpad.py 2010-04-27 02:11:35 +0000
97@@ -292,9 +292,7 @@
98
99 codeimportscheduler = Attribute("""Code import scheduler end point.""")
100
101- branch_puller = Attribute("""Branch puller end point.""")
102-
103- branchfilesystem = Attribute("""The branch filesystem end point.""")
104+ codehosting = Attribute("""Codehosting end point.""")
105
106 mailinglists = Attribute("""Mailing list XML-RPC end point.""")
107
108
109=== modified file 'lib/canonical/launchpad/systemhomes.py'
110--- lib/canonical/launchpad/systemhomes.py 2010-04-05 16:06:06 +0000
111+++ lib/canonical/launchpad/systemhomes.py 2010-04-27 02:11:35 +0000
112@@ -42,8 +42,7 @@
113 from canonical.launchpad.webapp.interfaces import ICanonicalUrlData
114 from lp.bugs.interfaces.bug import (
115 CreateBugParams, IBugSet, InvalidBugTargetType)
116-from lp.code.interfaces.codehosting import (
117- IBranchFileSystemApplication, IBranchPullerApplication)
118+from lp.code.interfaces.codehosting import ICodehostingApplication
119 from lp.code.interfaces.codeimportscheduler import (
120 ICodeImportSchedulerApplication)
121 from lp.registry.interfaces.product import IProduct
122@@ -61,18 +60,11 @@
123 title = "Auth Server"
124
125
126-class BranchFileSystemApplication:
127- """BranchFileSystem End-Point."""
128- implements(IBranchFileSystemApplication)
129-
130- title = "Branch File System"
131-
132-
133-class BranchPullerApplication:
134- """BranchPuller End-Point."""
135- implements(IBranchPullerApplication)
136-
137- title = "Puller API"
138+class CodehostingApplication:
139+ """Codehosting End-Point."""
140+ implements(ICodehostingApplication)
141+
142+ title = "Codehosting API"
143
144
145 class CodeImportSchedulerApplication:
146
147=== modified file 'lib/canonical/launchpad/xmlrpc/application.py'
148--- lib/canonical/launchpad/xmlrpc/application.py 2009-06-25 05:30:52 +0000
149+++ lib/canonical/launchpad/xmlrpc/application.py 2010-04-27 02:11:35 +0000
150@@ -24,8 +24,7 @@
151 IAuthServerApplication, ILaunchBag,
152 IMailingListApplication, IPrivateApplication,
153 IPrivateMaloneApplication)
154-from lp.code.interfaces.codehosting import (
155- IBranchFileSystemApplication, IBranchPullerApplication)
156+from lp.code.interfaces.codehosting import ICodehostingApplication
157 from lp.code.interfaces.codeimportscheduler import (
158 ICodeImportSchedulerApplication)
159 from canonical.launchpad.webapp import LaunchpadXMLRPCView
160@@ -45,14 +44,9 @@
161 return getUtility(IAuthServerApplication)
162
163 @property
164- def branch_puller(self):
165- """See `IPrivateApplication`."""
166- return getUtility(IBranchPullerApplication)
167-
168- @property
169- def branchfilesystem(self):
170- """See `IPrivateApplication`."""
171- return getUtility(IBranchFileSystemApplication)
172+ def codehosting(self):
173+ """See `IPrivateApplication`."""
174+ return getUtility(ICodehostingApplication)
175
176 @property
177 def codeimportscheduler(self):
178
179=== modified file 'lib/canonical/launchpad/xmlrpc/configure.zcml'
180--- lib/canonical/launchpad/xmlrpc/configure.zcml 2009-07-13 18:15:02 +0000
181+++ lib/canonical/launchpad/xmlrpc/configure.zcml 2010-04-27 02:11:35 +0000
182@@ -28,28 +28,15 @@
183 />
184
185 <securedutility
186- class="canonical.launchpad.systemhomes.BranchPullerApplication"
187- provides="lp.code.interfaces.codehosting.IBranchPullerApplication">
188- <allow interface="lp.code.interfaces.codehosting.IBranchPullerApplication"/>
189- </securedutility>
190-
191- <xmlrpc:view
192- for="lp.code.interfaces.codehosting.IBranchPullerApplication"
193- interface="lp.code.interfaces.codehosting.IBranchPuller"
194- class="lp.code.xmlrpc.codehosting.BranchPuller"
195- permission="zope.Public"
196- />
197-
198- <securedutility
199- class="canonical.launchpad.systemhomes.BranchFileSystemApplication"
200- provides="lp.code.interfaces.codehosting.IBranchFileSystemApplication">
201- <allow interface="lp.code.interfaces.codehosting.IBranchFileSystemApplication"/>
202- </securedutility>
203-
204- <xmlrpc:view
205- for="lp.code.interfaces.codehosting.IBranchFileSystemApplication"
206- interface="lp.code.interfaces.codehosting.IBranchFileSystem"
207- class="lp.code.xmlrpc.codehosting.BranchFileSystem"
208+ class="canonical.launchpad.systemhomes.CodehostingApplication"
209+ provides="lp.code.interfaces.codehosting.ICodehostingApplication">
210+ <allow interface="lp.code.interfaces.codehosting.ICodehostingApplication"/>
211+ </securedutility>
212+
213+ <xmlrpc:view
214+ for="lp.code.interfaces.codehosting.ICodehostingApplication"
215+ interface="lp.code.interfaces.codehosting.ICodehostingAPI"
216+ class="lp.code.xmlrpc.codehosting.CodehostingAPI"
217 permission="zope.Public"
218 />
219
220
221=== removed file 'lib/lp/code/doc/xmlrpc-branch-filesystem.txt'
222--- lib/lp/code/doc/xmlrpc-branch-filesystem.txt 2009-10-22 11:55:51 +0000
223+++ lib/lp/code/doc/xmlrpc-branch-filesystem.txt 1970-01-01 00:00:00 +0000
224@@ -1,31 +0,0 @@
225-= The BranchFileSystem application =
226-
227-The branch file system application is an XMLRPC service that provides
228-data for the virtual filesystems used by the codehosting service. It
229-is available as the branchfilesystem attribute of our private XMLRPC
230-instance.
231-
232- >>> from canonical.launchpad.interfaces import (
233- ... IPrivateApplication)
234- >>> from lp.code.interfaces.codehosting import (
235- ... IBranchFileSystemApplication)
236- >>> from canonical.launchpad.webapp.testing import verifyObject
237-
238- >>> private_root = getUtility(IPrivateApplication)
239- >>> verifyObject(
240- ... IBranchFileSystemApplication,
241- ... private_root.branchfilesystem)
242- True
243-
244-The end point is implemented by the BranchFileSystem, which implements
245-the IBranchFileSystem class.
246-
247- >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
248- >>> from lp.code.interfaces.codehosting import IBranchFileSystem
249- >>> from lp.code.xmlrpc.codehosting import (
250- ... BranchFileSystem)
251-
252- >>> branchfs_api = BranchFileSystem(
253- ... private_root.branchfilesystem, LaunchpadTestRequest())
254- >>> verifyObject(IBranchFileSystem, branchfs_api)
255- True
256
257=== removed file 'lib/lp/code/doc/xmlrpc-branch-puller.txt'
258--- lib/lp/code/doc/xmlrpc-branch-puller.txt 2010-02-24 01:57:35 +0000
259+++ lib/lp/code/doc/xmlrpc-branch-puller.txt 1970-01-01 00:00:00 +0000
260@@ -1,31 +0,0 @@
261-= The BranchPuller application =
262-
263-The branch puller application is an XMLRPC service that allows the puller
264-to find and update the status of branches. It is available as the
265-branch_puller attribute of our private XMLRPC instance.
266-
267- >>> from canonical.launchpad.interfaces import (
268- ... IPrivateApplication)
269- >>> from lp.code.interfaces.codehosting import (
270- ... IBranchPullerApplication)
271- >>> from canonical.launchpad.webapp.testing import verifyObject
272-
273- >>> private_root = getUtility(IPrivateApplication)
274- >>> verifyObject(
275- ... IBranchPullerApplication,
276- ... private_root.branch_puller)
277- True
278-
279-The BranchPuller view provides the IBranchPuller XML-RPC API:
280-
281- >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
282- >>> from lp.code.interfaces.codehosting import IBranchPuller
283- >>> from lp.code.xmlrpc.codehosting import BranchPuller
284-
285- >>> branch_puller = BranchPuller(
286- ... private_root.branch_puller, LaunchpadTestRequest())
287- >>> verifyObject(IBranchPuller, branch_puller)
288- True
289-
290-The IBranchPuller interface defines some methods, for which see the unit
291-tests.
292
293=== added file 'lib/lp/code/doc/xmlrpc-codehosting.txt'
294--- lib/lp/code/doc/xmlrpc-codehosting.txt 1970-01-01 00:00:00 +0000
295+++ lib/lp/code/doc/xmlrpc-codehosting.txt 2010-04-27 02:11:35 +0000
296@@ -0,0 +1,32 @@
297+= The BranchPuller application =
298+
299+The codehosting application is an XMLRPC service that allows the
300+codehosting service and puller to find and update the status of
301+branches. It is available as the codehosting attribute of our private
302+XMLRPC instance.
303+
304+ >>> from canonical.launchpad.interfaces import (
305+ ... IPrivateApplication)
306+ >>> from lp.code.interfaces.codehosting import (
307+ ... ICodehostingApplication)
308+ >>> from canonical.launchpad.webapp.testing import verifyObject
309+
310+ >>> private_root = getUtility(IPrivateApplication)
311+ >>> verifyObject(
312+ ... ICodehostingApplication,
313+ ... private_root.codehosting)
314+ True
315+
316+The CodeHosting view provides the ICodehostingAPI XML-RPC API:
317+
318+ >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
319+ >>> from lp.code.interfaces.codehosting import ICodehostingAPI
320+ >>> from lp.code.xmlrpc.codehosting import CodehostingAPI
321+
322+ >>> codehosting_api = CodehostingAPI(
323+ ... private_root.codehosting, LaunchpadTestRequest())
324+ >>> verifyObject(ICodehostingAPI, codehosting_api)
325+ True
326+
327+The ICodehostingAPI interface defines some methods, for which see the
328+unit tests.
329
330=== modified file 'lib/lp/code/interfaces/codehosting.py'
331--- lib/lp/code/interfaces/codehosting.py 2010-04-27 02:11:16 +0000
332+++ lib/lp/code/interfaces/codehosting.py 2010-04-27 02:11:35 +0000
333@@ -9,10 +9,8 @@
334 __all__ = [
335 'BRANCH_TRANSPORT',
336 'CONTROL_TRANSPORT',
337- 'IBranchPuller',
338- 'IBranchPullerApplication',
339- 'IBranchFileSystem',
340- 'IBranchFileSystemApplication',
341+ 'ICodehostingAPI',
342+ 'ICodehostingApplication',
343 'LAUNCHPAD_ANONYMOUS',
344 'LAUNCHPAD_SERVICES',
345 'READ_ONLY',
346@@ -48,14 +46,17 @@
347 CONTROL_TRANSPORT = 'CONTROL_TRANSPORT'
348
349
350-class IBranchPullerApplication(ILaunchpadApplication):
351+class ICodehostingApplication(ILaunchpadApplication):
352 """Branch Puller application root."""
353
354
355-class IBranchPuller(Interface):
356- """The puller's interface to the rest of Launchpad.
357-
358- Published at 'branch_puller' on the private XML-RPC server.
359+class ICodehostingAPI(Interface):
360+ """The codehosting XML-RPC interface to Launchpad.
361+
362+ Published at 'codehosting' on the private XML-RPC server.
363+
364+ The code hosting service and puller use this to register branches, to
365+ retrieve information about a user's branches, and to update their status.
366 """
367
368 def acquireBranchToPull(branch_type_names):
369@@ -144,20 +145,6 @@
370 'stacked_on_location'.
371 """
372
373-
374-class IBranchFileSystemApplication(ILaunchpadApplication):
375- """Branch File System end point root."""
376-
377-
378-class IBranchFileSystem(Interface):
379- """An interface for dealing with hosted branches in Launchpad.
380-
381- Published at `branchfilesystem`.
382-
383- The code hosting service uses this to register branches, to retrieve
384- information about a user's branches, and to update their status.
385- """
386-
387 def createBranch(login_id, branch_path):
388 """Register a new hosted branch in Launchpad.
389
390
391=== modified file 'lib/lp/code/xmlrpc/codehosting.py'
392--- lib/lp/code/xmlrpc/codehosting.py 2010-04-27 02:11:16 +0000
393+++ lib/lp/code/xmlrpc/codehosting.py 2010-04-27 02:11:35 +0000
394@@ -5,8 +5,7 @@
395
396 __metaclass__ = type
397 __all__ = [
398- 'BranchFileSystem',
399- 'BranchPuller',
400+ 'CodehostingAPI',
401 'datetime_from_tuple',
402 ]
403
404@@ -43,8 +42,8 @@
405 InvalidNamespace, lookup_branch_namespace, split_unique_name)
406 from lp.code.interfaces import branchpuller
407 from lp.code.interfaces.codehosting import (
408- BRANCH_TRANSPORT, CONTROL_TRANSPORT, IBranchFileSystem, IBranchPuller,
409- LAUNCHPAD_ANONYMOUS, LAUNCHPAD_SERVICES)
410+ BRANCH_TRANSPORT, CONTROL_TRANSPORT, ICodehostingAPI, LAUNCHPAD_ANONYMOUS,
411+ LAUNCHPAD_SERVICES)
412 from lp.registry.interfaces.person import IPersonSet, NoSuchPerson
413 from lp.registry.interfaces.product import NoSuchProduct
414 from lp.services.scripts.interfaces.scriptactivity import IScriptActivitySet
415@@ -54,13 +53,54 @@
416 UTC = pytz.timezone('UTC')
417
418
419-class BranchPuller(LaunchpadXMLRPCView):
420- """See `IBranchPuller`."""
421-
422- implements(IBranchPuller)
423+def datetime_from_tuple(time_tuple):
424+ """Create a datetime from a sequence that quacks like time.struct_time.
425+
426+ The tm_isdst is (index 8) is ignored. The created datetime uses
427+ tzinfo=UTC.
428+ """
429+ [year, month, day, hour, minute, second, unused, unused, unused] = (
430+ time_tuple)
431+ return datetime.datetime(
432+ year, month, day, hour, minute, second, tzinfo=UTC)
433+
434+
435+def run_with_login(login_id, function, *args, **kwargs):
436+ """Run 'function' logged in with 'login_id'.
437+
438+ The first argument passed to 'function' will be the Launchpad
439+ `Person` object corresponding to 'login_id'.
440+
441+ The exception is when the requesting login ID is `LAUNCHPAD_SERVICES`. In
442+ that case, we'll pass through the `LAUNCHPAD_SERVICES` variable and the
443+ method will do whatever security proxy hackery is required to provide read
444+ privileges to the Launchpad services.
445+ """
446+ if login_id == LAUNCHPAD_SERVICES or login_id == LAUNCHPAD_ANONYMOUS:
447+ # Don't pass in an actual user. Instead pass in LAUNCHPAD_SERVICES
448+ # and expect `function` to use `removeSecurityProxy` or similar.
449+ return function(login_id, *args, **kwargs)
450+ if isinstance(login_id, basestring):
451+ requester = getUtility(IPersonSet).getByName(login_id)
452+ else:
453+ requester = getUtility(IPersonSet).get(login_id)
454+ if requester is None:
455+ raise NotFoundError("No person with id %s." % login_id)
456+ setupInteractionForPerson(requester)
457+ try:
458+ return function(requester, *args, **kwargs)
459+ finally:
460+ endInteraction()
461+
462+
463+
464+class CodehostingAPI(LaunchpadXMLRPCView):
465+ """See `ICodehostingAPI`."""
466+
467+ implements(ICodehostingAPI)
468
469 def acquireBranchToPull(self, branch_type_names):
470- """See `IBranchPuller`."""
471+ """See `ICodehostingAPI`."""
472 branch_types = []
473 for branch_type_name in branch_type_names:
474 try:
475@@ -86,7 +126,7 @@
476 return ()
477
478 def mirrorComplete(self, branch_id, last_revision_id):
479- """See `IBranchPuller`."""
480+ """See `ICodehostingAPI`."""
481 branch = getUtility(IBranchLookup).get(branch_id)
482 if branch is None:
483 return faults.NoBranchWithID(branch_id)
484@@ -96,7 +136,7 @@
485 return True
486
487 def mirrorFailed(self, branch_id, reason):
488- """See `IBranchPuller`."""
489+ """See `ICodehostingAPI`."""
490 branch = getUtility(IBranchLookup).get(branch_id)
491 if branch is None:
492 return faults.NoBranchWithID(branch_id)
493@@ -105,7 +145,7 @@
494 return True
495
496 def recordSuccess(self, name, hostname, started_tuple, completed_tuple):
497- """See `IBranchPuller`."""
498+ """See `ICodehostingAPI`."""
499 date_started = datetime_from_tuple(started_tuple)
500 date_completed = datetime_from_tuple(completed_tuple)
501 getUtility(IScriptActivitySet).recordSuccess(
502@@ -114,7 +154,7 @@
503 return True
504
505 def startMirroring(self, branch_id):
506- """See `IBranchPuller`."""
507+ """See `ICodehostingAPI`."""
508 branch = getUtility(IBranchLookup).get(branch_id)
509 if branch is None:
510 return faults.NoBranchWithID(branch_id)
511@@ -124,7 +164,7 @@
512 return True
513
514 def setStackedOn(self, branch_id, stacked_on_location):
515- """See `IBranchPuller`."""
516+ """See `ICodehostingAPI`."""
517 # We don't want the security proxy on the branch set because this
518 # method should be able to see all branches and set stacking
519 # information on any of them.
520@@ -146,54 +186,8 @@
521 stacked_branch.stacked_on = stacked_on_branch
522 return True
523
524-
525-def datetime_from_tuple(time_tuple):
526- """Create a datetime from a sequence that quacks like time.struct_time.
527-
528- The tm_isdst is (index 8) is ignored. The created datetime uses
529- tzinfo=UTC.
530- """
531- [year, month, day, hour, minute, second, unused, unused, unused] = (
532- time_tuple)
533- return datetime.datetime(
534- year, month, day, hour, minute, second, tzinfo=UTC)
535-
536-
537-def run_with_login(login_id, function, *args, **kwargs):
538- """Run 'function' logged in with 'login_id'.
539-
540- The first argument passed to 'function' will be the Launchpad
541- `Person` object corresponding to 'login_id'.
542-
543- The exception is when the requesting login ID is `LAUNCHPAD_SERVICES`. In
544- that case, we'll pass through the `LAUNCHPAD_SERVICES` variable and the
545- method will do whatever security proxy hackery is required to provide read
546- privileges to the Launchpad services.
547- """
548- if login_id == LAUNCHPAD_SERVICES or login_id == LAUNCHPAD_ANONYMOUS:
549- # Don't pass in an actual user. Instead pass in LAUNCHPAD_SERVICES
550- # and expect `function` to use `removeSecurityProxy` or similar.
551- return function(login_id, *args, **kwargs)
552- if isinstance(login_id, basestring):
553- requester = getUtility(IPersonSet).getByName(login_id)
554- else:
555- requester = getUtility(IPersonSet).get(login_id)
556- if requester is None:
557- raise NotFoundError("No person with id %s." % login_id)
558- setupInteractionForPerson(requester)
559- try:
560- return function(requester, *args, **kwargs)
561- finally:
562- endInteraction()
563-
564-
565-class BranchFileSystem(LaunchpadXMLRPCView):
566- """See `IBranchFileSystem`."""
567-
568- implements(IBranchFileSystem)
569-
570 def createBranch(self, login_id, branch_path):
571- """See `IBranchFileSystem`."""
572+ """See `ICodehostingAPI`."""
573 def create_branch(requester):
574 if not branch_path.startswith('/'):
575 return faults.InvalidPath(branch_path)
576@@ -238,7 +232,7 @@
577 and check_permission('launchpad.Edit', branch))
578
579 def requestMirror(self, login_id, branchID):
580- """See `IBranchFileSystem`."""
581+ """See `ICodehostingAPI`."""
582 def request_mirror(requester):
583 branch = getUtility(IBranchLookup).get(branchID)
584 # We don't really care who requests a mirror of a branch.
585@@ -248,7 +242,7 @@
586
587 def branchChanged(self, branch_id, stacked_on_location, last_revision_id,
588 control_string, branch_string, repository_string):
589- """See `IBranchFileSystem`."""
590+ """See `ICodehostingAPI`."""
591 branch_set = removeSecurityProxy(getUtility(IBranchLookup))
592 branch = branch_set.get(branch_id)
593 if branch is None:
594@@ -322,7 +316,7 @@
595 trailing_path)
596
597 def translatePath(self, requester_id, path):
598- """See `IBranchFileSystem`."""
599+ """See `ICodehostingAPI`."""
600 @return_fault
601 def translate_path(requester):
602 if not path.startswith('/'):
603
604=== modified file 'lib/lp/code/xmlrpc/tests/test_codehosting.py'
605--- lib/lp/code/xmlrpc/tests/test_codehosting.py 2010-04-27 02:11:16 +0000
606+++ lib/lp/code/xmlrpc/tests/test_codehosting.py 2010-04-27 02:11:35 +0000
607@@ -20,8 +20,7 @@
608 from canonical.launchpad.ftests import ANONYMOUS, login, logout
609 from lp.services.scripts.interfaces.scriptactivity import (
610 IScriptActivitySet)
611-from lp.code.interfaces.codehosting import (
612- BRANCH_TRANSPORT, CONTROL_TRANSPORT)
613+from lp.code.interfaces.codehosting import BRANCH_TRANSPORT, CONTROL_TRANSPORT
614 from canonical.launchpad.interfaces.launchpad import ILaunchBag
615 from lp.testing import TestCaseWithFactory
616 from lp.testing.factory import LaunchpadObjectFactory
617@@ -38,8 +37,7 @@
618 from lp.code.interfaces.branchtarget import IBranchTarget
619 from lp.code.model.tests.test_branchpuller import AcquireBranchToPullTests
620 from lp.code.xmlrpc.codehosting import (
621- BranchFileSystem, BranchPuller, LAUNCHPAD_ANONYMOUS, LAUNCHPAD_SERVICES,
622- run_with_login)
623+ CodehostingAPI, LAUNCHPAD_ANONYMOUS, LAUNCHPAD_SERVICES, run_with_login)
624
625 from lp.codehosting.inmemory import InMemoryFrontend
626
627@@ -126,17 +124,17 @@
628 self.assertEqual(None, login_id)
629
630
631-class BranchPullerTest(TestCaseWithFactory):
632- """Tests for the implementation of `IBranchPuller`.
633+class CodehostingTest(TestCaseWithFactory):
634+ """Tests for the implementation of `ICodehostingAPI`.
635
636 :ivar frontend: A nullary callable that returns an object that implements
637- getPullerEndpoint, getLaunchpadObjectFactory and getBranchLookup.
638+ getCodehostingEndpoint, getLaunchpadObjectFactory and getBranchLookup.
639 """
640
641 def setUp(self):
642 TestCaseWithFactory.setUp(self)
643 frontend = self.frontend()
644- self.storage = frontend.getPullerEndpoint()
645+ self.codehosting_api = frontend.getCodehostingEndpoint()
646 self.factory = frontend.getLaunchpadObjectFactory()
647 self.branch_lookup = frontend.getBranchLookup()
648 self.getLastActivity = frontend.getLastActivity
649@@ -189,7 +187,7 @@
650 branch = self.factory.makeAnyBranch()
651 self.assertUnmirrored(branch)
652
653- success = self.storage.startMirroring(branch.id)
654+ success = self.codehosting_api.startMirroring(branch.id)
655 self.assertEqual(success, True)
656
657 self.assertSqlAttributeEqualsDate(
658@@ -200,23 +198,23 @@
659 # startMirroring returns False when given a branch id which does not
660 # exist.
661 invalid_id = self.getUnusedBranchID()
662- fault = self.storage.startMirroring(invalid_id)
663+ fault = self.codehosting_api.startMirroring(invalid_id)
664 self.assertEqual(faults.NoBranchWithID(invalid_id), fault)
665
666 def test_mirrorFailed(self):
667 branch = self.factory.makeAnyBranch()
668 self.assertUnmirrored(branch)
669
670- self.storage.startMirroring(branch.id)
671+ self.codehosting_api.startMirroring(branch.id)
672 failure_message = self.factory.getUniqueString()
673- success = self.storage.mirrorFailed(branch.id, failure_message)
674+ success = self.codehosting_api.mirrorFailed(branch.id, failure_message)
675 self.assertEqual(True, success)
676 self.assertMirrorFailed(branch, failure_message)
677
678 def test_mirrorFailedWithNotBranchID(self):
679 branch_id = self.getUnusedBranchID()
680 failure_message = self.factory.getUniqueString()
681- fault = self.storage.mirrorFailed(branch_id, failure_message)
682+ fault = self.codehosting_api.mirrorFailed(branch_id, failure_message)
683 self.assertEqual(faults.NoBranchWithID(branch_id), fault)
684
685 def test_mirrorComplete(self):
686@@ -225,9 +223,9 @@
687 branch = self.factory.makeAnyBranch()
688 self.assertUnmirrored(branch)
689
690- self.storage.startMirroring(branch.id)
691+ self.codehosting_api.startMirroring(branch.id)
692 revision_id = self.factory.getUniqueString()
693- success = self.storage.mirrorComplete(branch.id, revision_id)
694+ success = self.codehosting_api.mirrorComplete(branch.id, revision_id)
695 self.assertEqual(True, success)
696 self.assertMirrorSucceeded(branch, revision_id)
697
698@@ -235,7 +233,7 @@
699 # mirrorComplete returns a Fault if there's no branch with the given
700 # ID.
701 branch_id = self.getUnusedBranchID()
702- fault = self.storage.mirrorComplete(
703+ fault = self.codehosting_api.mirrorComplete(
704 branch_id, self.factory.getUniqueString())
705 self.assertEqual(faults.NoBranchWithID(branch_id), fault)
706
707@@ -245,15 +243,15 @@
708
709 # First, mark the branch as failed.
710 branch = self.factory.makeAnyBranch()
711- self.storage.startMirroring(branch.id)
712+ self.codehosting_api.startMirroring(branch.id)
713 failure_message = self.factory.getUniqueString()
714- self.storage.mirrorFailed(branch.id, failure_message)
715+ self.codehosting_api.mirrorFailed(branch.id, failure_message)
716 self.assertMirrorFailed(branch, failure_message)
717
718 # Start and successfully finish a mirror.
719- self.storage.startMirroring(branch.id)
720+ self.codehosting_api.startMirroring(branch.id)
721 revision_id = self.factory.getUniqueString()
722- self.storage.mirrorComplete(branch.id, revision_id)
723+ self.codehosting_api.mirrorComplete(branch.id, revision_id)
724
725 # Confirm that it succeeded.
726 self.assertMirrorSucceeded(branch, revision_id)
727@@ -267,8 +265,9 @@
728 branch.requestMirror()
729
730 # Simulate successfully mirroring the branch.
731- self.storage.startMirroring(branch.id)
732- self.storage.mirrorComplete(branch.id, self.factory.getUniqueString())
733+ self.codehosting_api.startMirroring(branch.id)
734+ self.codehosting_api.mirrorComplete(
735+ branch.id, self.factory.getUniqueString())
736
737 self.assertIs(None, branch.next_mirror_time)
738
739@@ -278,7 +277,7 @@
740 completed = datetime.datetime(2007, 07, 05, 19, 34, 24, tzinfo=UTC)
741 started_tuple = tuple(started.utctimetuple())
742 completed_tuple = tuple(completed.utctimetuple())
743- success = self.storage.recordSuccess(
744+ success = self.codehosting_api.recordSuccess(
745 'test-recordsuccess', 'vostok', started_tuple, completed_tuple)
746 self.assertEqual(True, success)
747
748@@ -293,7 +292,7 @@
749 # generated as part of Launchpad's default stacking.
750 stacked_branch = self.factory.makeAnyBranch()
751 stacked_on_branch = self.factory.makeAnyBranch()
752- self.storage.setStackedOn(
753+ self.codehosting_api.setStackedOn(
754 stacked_branch.id, '/%s' % stacked_on_branch.unique_name)
755 self.assertEqual(stacked_branch.stacked_on, stacked_on_branch)
756
757@@ -304,7 +303,8 @@
758 stacked_branch = self.factory.makeAnyBranch()
759 stacked_on_branch = self.factory.makeAnyBranch(
760 branch_type=BranchType.MIRRORED)
761- self.storage.setStackedOn(stacked_branch.id, stacked_on_branch.url)
762+ self.codehosting_api.setStackedOn(
763+ stacked_branch.id, stacked_on_branch.url)
764 self.assertEqual(stacked_branch.stacked_on, stacked_on_branch)
765
766 def test_setStackedOnExternalURLWithTrailingSlash(self):
767@@ -315,7 +315,7 @@
768 stacked_on_branch = self.factory.makeAnyBranch(
769 branch_type=BranchType.MIRRORED)
770 url = stacked_on_branch.url + '/'
771- self.storage.setStackedOn(stacked_branch.id, url)
772+ self.codehosting_api.setStackedOn(stacked_branch.id, url)
773 self.assertEqual(stacked_branch.stacked_on, stacked_on_branch)
774
775 def test_setStackedOnNothing(self):
776@@ -324,7 +324,7 @@
777 stacked_on_branch = self.factory.makeAnyBranch()
778 stacked_branch = self.factory.makeAnyBranch(
779 stacked_on=stacked_on_branch)
780- self.storage.setStackedOn(stacked_branch.id, '')
781+ self.codehosting_api.setStackedOn(stacked_branch.id, '')
782 self.assertIs(stacked_branch.stacked_on, None)
783
784 def test_setStackedOnBranchNotFound(self):
785@@ -332,7 +332,7 @@
786 # return a Fault.
787 stacked_branch = self.factory.makeAnyBranch()
788 url = self.factory.getUniqueURL()
789- fault = self.storage.setStackedOn(stacked_branch.id, url)
790+ fault = self.codehosting_api.setStackedOn(stacked_branch.id, url)
791 self.assertEqual(faults.NoSuchBranch(url), fault)
792
793 def test_setStackedOnNoBranchWithID(self):
794@@ -341,110 +341,17 @@
795 stacked_on_branch = self.factory.makeAnyBranch(
796 branch_type=BranchType.MIRRORED)
797 branch_id = self.getUnusedBranchID()
798- fault = self.storage.setStackedOn(branch_id, stacked_on_branch.url)
799+ fault = self.codehosting_api.setStackedOn(
800+ branch_id, stacked_on_branch.url)
801 self.assertEqual(faults.NoBranchWithID(branch_id), fault)
802
803-
804-class AcquireBranchToPullTestsViaEndpoint(TestCaseWithFactory,
805- AcquireBranchToPullTests):
806- """Tests for `acquireBranchToPull` method of `IBranchPuller`."""
807-
808- def setUp(self):
809- super(AcquireBranchToPullTestsViaEndpoint, self).setUp()
810- frontend = self.frontend()
811- self.storage = frontend.getPullerEndpoint()
812- self.factory = frontend.getLaunchpadObjectFactory()
813-
814- def assertNoBranchIsAquired(self, *branch_types):
815- """See `AcquireBranchToPullTests`."""
816- branch_types = tuple(branch_type.name for branch_type in branch_types)
817- pull_info = self.storage.acquireBranchToPull(branch_types)
818- self.assertEqual((), pull_info)
819-
820- def assertBranchIsAquired(self, branch, *branch_types):
821- """See `AcquireBranchToPullTests`."""
822- branch = removeSecurityProxy(branch)
823- branch_types = tuple(branch_type.name for branch_type in branch_types)
824- pull_info = self.storage.acquireBranchToPull(branch_types)
825- default_branch = branch.target.default_stacked_on_branch
826- if default_branch:
827- default_branch_name = default_branch
828- else:
829- default_branch_name = ''
830- self.assertEqual(
831- pull_info,
832- (branch.id, branch.getPullURL(), branch.unique_name,
833- default_branch_name, branch.branch_type.name))
834- self.assertIsNot(None, branch.last_mirror_attempt)
835- self.assertIs(None, branch.next_mirror_time)
836-
837- def startMirroring(self, branch):
838- """See `AcquireBranchToPullTests`."""
839- self.storage.startMirroring(branch.id)
840-
841- def test_branch_type_returned_mirrored(self):
842- branch = self.factory.makeAnyBranch(branch_type=BranchType.MIRRORED)
843- branch.requestMirror()
844- pull_info = self.storage.acquireBranchToPull(())
845- _, _, _, _, branch_type = pull_info
846- self.assertEqual('MIRRORED', branch_type)
847-
848- def test_branch_type_returned_import(self):
849- branch = self.factory.makeAnyBranch(branch_type=BranchType.IMPORTED)
850- branch.requestMirror()
851- pull_info = self.storage.acquireBranchToPull(())
852- _, _, _, _, branch_type = pull_info
853- self.assertEqual('IMPORTED', branch_type)
854-
855- def test_default_stacked_on_branch_returned(self):
856- branch = self.factory.makeProductBranch(
857- branch_type=BranchType.MIRRORED)
858- self.factory.enableDefaultStackingForProduct(branch.product)
859- branch.requestMirror()
860- pull_info = self.storage.acquireBranchToPull(())
861- _, _, _, default_stacked_on_branch, _ = pull_info
862- self.assertEqual(
863- default_stacked_on_branch,
864- '/' + branch.target.default_stacked_on_branch.unique_name)
865-
866- def test_private_default_stacked_not_returned_for_mirrored_branch(self):
867- # We don't stack mirrored branches on a private default stacked on
868- # branch.
869- product = self.factory.makeProduct()
870- default_branch = self.factory.makeProductBranch(
871- product=product, private=True)
872- self.factory.enableDefaultStackingForProduct(product, default_branch)
873- mirrored_branch = self.factory.makeProductBranch(
874- branch_type=BranchType.MIRRORED, product=product)
875- mirrored_branch.requestMirror()
876- pull_info = self.storage.acquireBranchToPull(())
877- _, _, _, default_stacked_on_branch, _ = pull_info
878- self.assertEqual(
879- '', default_stacked_on_branch)
880-
881- def test_unknown_branch_type_name_raises(self):
882- self.assertRaises(
883- UnknownBranchTypeError, self.storage.acquireBranchToPull,
884- ('NO_SUCH_TYPE',))
885-
886-
887-class BranchFileSystemTest(TestCaseWithFactory):
888- """Tests for the implementation of `IBranchFileSystem`."""
889-
890- def setUp(self):
891- super(BranchFileSystemTest, self).setUp()
892- frontend = self.frontend()
893- self.branchfs = frontend.getFilesystemEndpoint()
894- self.factory = frontend.getLaunchpadObjectFactory()
895- self.branch_lookup = frontend.getBranchLookup()
896-
897 def test_createBranch(self):
898 # createBranch creates a branch with the supplied details and the
899 # caller as registrant.
900 owner = self.factory.makePerson()
901 product = self.factory.makeProduct()
902 name = self.factory.getUniqueString()
903- branch_id = self.branchfs.createBranch(
904+ branch_id = self.codehosting_api.createBranch(
905 owner.id, escape('/~%s/%s/%s' % (owner.name, product.name, name)))
906 login(ANONYMOUS)
907 branch = self.branch_lookup.get(branch_id)
908@@ -457,7 +364,7 @@
909 def test_createBranch_no_preceding_slash(self):
910 requester = self.factory.makePerson()
911 path = escape(u'invalid')
912- fault = self.branchfs.createBranch(requester.id, path)
913+ fault = self.codehosting_api.createBranch(requester.id, path)
914 login(ANONYMOUS)
915 self.assertEqual(faults.InvalidPath(path), fault)
916
917@@ -465,7 +372,7 @@
918 # createBranch can create +junk branches.
919 owner = self.factory.makePerson()
920 name = self.factory.getUniqueString()
921- branch_id = self.branchfs.createBranch(
922+ branch_id = self.codehosting_api.createBranch(
923 owner.id, escape('/~%s/%s/%s' % (owner.name, '+junk', name)))
924 login(ANONYMOUS)
925 branch = self.branch_lookup.get(branch_id)
926@@ -480,7 +387,7 @@
927 registrant = self.factory.makePerson()
928 team = self.factory.makeTeam(registrant)
929 name = self.factory.getUniqueString()
930- branch_id = self.branchfs.createBranch(
931+ branch_id = self.codehosting_api.createBranch(
932 registrant.id, escape('/~%s/+junk/%s' % (team.name, name)))
933 login(ANONYMOUS)
934 branch = self.branch_lookup.get(branch_id)
935@@ -495,7 +402,7 @@
936 owner = self.factory.makePerson()
937 name = self.factory.getUniqueString()
938 message = "Project 'no-such-product' does not exist."
939- fault = self.branchfs.createBranch(
940+ fault = self.codehosting_api.createBranch(
941 owner.id, escape('/~%s/no-such-product/%s' % (owner.name, name)))
942 self.assertEqual(faults.NotFound(message), fault)
943
944@@ -507,7 +414,7 @@
945 name = self.factory.getUniqueString()
946 message = ("%s cannot create branches owned by %s"
947 % (creator.displayname, other_person.displayname))
948- fault = self.branchfs.createBranch(
949+ fault = self.codehosting_api.createBranch(
950 creator.id,
951 escape('/~%s/%s/%s' % (other_person.name, product.name, name)))
952 self.assertEqual(faults.PermissionDenied(message), fault)
953@@ -519,7 +426,7 @@
954 invalid_name = 'invalid name!'
955 message = ("Invalid branch name '%s'. %s"
956 % (invalid_name, BRANCH_NAME_VALIDATION_ERROR_MESSAGE))
957- fault = self.branchfs.createBranch(
958+ fault = self.codehosting_api.createBranch(
959 owner.id, escape(
960 '/~%s/%s/%s' % (owner.name, product.name, invalid_name)))
961 self.assertEqual(faults.PermissionDenied(message), fault)
962@@ -532,7 +439,7 @@
963 message = ("Invalid branch name '%s'. %s"
964 % (invalid_name.encode('utf-8'),
965 str(BRANCH_NAME_VALIDATION_ERROR_MESSAGE)))
966- fault = self.branchfs.createBranch(
967+ fault = self.codehosting_api.createBranch(
968 owner.id, escape(
969 '/~%s/%s/%s' % (owner.name, product.name, invalid_name)))
970 self.assertEqual(
971@@ -544,7 +451,7 @@
972 product = self.factory.makeProduct()
973 name = self.factory.getUniqueString()
974 message = "User/team 'no-one' does not exist."
975- fault = self.branchfs.createBranch(
976+ fault = self.codehosting_api.createBranch(
977 owner.id, escape('/~no-one/%s/%s' % (product.name, name)))
978 self.assertEqual(faults.NotFound(message), fault)
979
980@@ -555,7 +462,7 @@
981 owner = self.factory.makePerson()
982 name = self.factory.getUniqueString()
983 message = "User/team 'no-one' does not exist."
984- fault = self.branchfs.createBranch(
985+ fault = self.codehosting_api.createBranch(
986 owner.id, escape('/~no-one/no-product/%s' % (name,)))
987 self.assertEqual(faults.NotFound(message), fault)
988
989@@ -564,7 +471,7 @@
990 # raises a PermissionDenied fault.
991 owner = self.factory.makePerson()
992 path = escape('/~%s' % owner.name)
993- fault = self.branchfs.createBranch(owner.id, path)
994+ fault = self.codehosting_api.createBranch(owner.id, path)
995 message = "Cannot create branch at '%s'" % path
996 self.assertEqual(faults.PermissionDenied(message), fault)
997
998@@ -580,7 +487,8 @@
999 sourcepackage.distroseries.name,
1000 sourcepackage.sourcepackagename.name,
1001 branch_name)
1002- branch_id = self.branchfs.createBranch(owner.id, escape(unique_name))
1003+ branch_id = self.codehosting_api.createBranch(
1004+ owner.id, escape(unique_name))
1005 login(ANONYMOUS)
1006 branch = self.branch_lookup.get(branch_id)
1007 self.assertEqual(owner, branch.owner)
1008@@ -601,7 +509,7 @@
1009 unique_name = '/~%s/ningnangnong/%s/%s/%s' % (
1010 owner.name, distroseries.name, sourcepackagename.name,
1011 branch_name)
1012- fault = self.branchfs.createBranch(owner.id, escape(unique_name))
1013+ fault = self.codehosting_api.createBranch(owner.id, escape(unique_name))
1014 message = "No such distribution: 'ningnangnong'."
1015 self.assertEqual(faults.NotFound(message), fault)
1016
1017@@ -615,7 +523,8 @@
1018 unique_name = '/~%s/%s/ningnangnong/%s/%s' % (
1019 owner.name, distribution.name, sourcepackagename.name,
1020 branch_name)
1021- fault = self.branchfs.createBranch(owner.id, escape(unique_name))
1022+ fault = self.codehosting_api.createBranch(
1023+ owner.id, escape(unique_name))
1024 message = "No such distribution series: 'ningnangnong'."
1025 self.assertEqual(faults.NotFound(message), fault)
1026
1027@@ -628,7 +537,7 @@
1028 unique_name = '/~%s/%s/%s/ningnangnong/%s' % (
1029 owner.name, distroseries.distribution.name, distroseries.name,
1030 branch_name)
1031- fault = self.branchfs.createBranch(owner.id, escape(unique_name))
1032+ fault = self.codehosting_api.createBranch(owner.id, escape(unique_name))
1033 message = "No such source package: 'ningnangnong'."
1034 self.assertEqual(faults.NotFound(message), fault)
1035
1036@@ -643,7 +552,7 @@
1037 # current time.
1038 requester = self.factory.makePerson()
1039 branch = self.factory.makeAnyBranch(branch_type=BranchType.HOSTED)
1040- self.branchfs.requestMirror(requester.id, branch.id)
1041+ self.codehosting_api.requestMirror(requester.id, branch.id)
1042 self.assertSqlAttributeEqualsDate(
1043 branch, 'next_mirror_time', UTC_NOW)
1044
1045@@ -652,7 +561,7 @@
1046 requester = self.factory.makePerson()
1047 branch = self.factory.makeAnyBranch(owner=requester, private=True)
1048 branch = removeSecurityProxy(branch)
1049- self.branchfs.requestMirror(requester.id, branch.id)
1050+ self.codehosting_api.requestMirror(requester.id, branch.id)
1051 self.assertSqlAttributeEqualsDate(
1052 branch, 'next_mirror_time', UTC_NOW)
1053
1054@@ -672,7 +581,7 @@
1055 # branchChanged sets the last_mirrored_id attribute on the branch.
1056 revid = self.factory.getUniqueString()
1057 branch = self.factory.makeAnyBranch()
1058- self.branchfs.branchChanged(
1059+ self.codehosting_api.branchChanged(
1060 branch.id, '', revid, *self.arbitrary_format_strings)
1061 self.assertEqual(revid, branch.last_mirrored_id)
1062
1063@@ -681,7 +590,7 @@
1064 # passed in.
1065 branch = self.factory.makeAnyBranch()
1066 stacked_on = self.factory.makeAnyBranch()
1067- self.branchfs.branchChanged(
1068+ self.codehosting_api.branchChanged(
1069 branch.id, stacked_on.unique_name, '',
1070 *self.arbitrary_format_strings)
1071 self.assertEqual(stacked_on, branch.stacked_on)
1072@@ -691,7 +600,7 @@
1073 # passed in as the stacked_on location.
1074 branch = self.factory.makeAnyBranch()
1075 removeSecurityProxy(branch).stacked_on = self.factory.makeAnyBranch()
1076- self.branchfs.branchChanged(
1077+ self.codehosting_api.branchChanged(
1078 branch.id, '', '', *self.arbitrary_format_strings)
1079 self.assertIs(None, branch.stacked_on)
1080
1081@@ -699,7 +608,7 @@
1082 # branchChanged sets the last_mirrored attribute on the branch to the
1083 # current time.
1084 branch = self.factory.makeAnyBranch()
1085- self.branchfs.branchChanged(
1086+ self.codehosting_api.branchChanged(
1087 branch.id, '', '', *self.arbitrary_format_strings)
1088 if self.frontend == LaunchpadDatabaseFrontend:
1089 self.assertSqlAttributeEqualsDate(
1090@@ -712,7 +621,7 @@
1091 # mirror_status_message is set to indicate the problem and stacked_on
1092 # set to None.
1093 branch = self.factory.makeAnyBranch()
1094- self.branchfs.branchChanged(
1095+ self.codehosting_api.branchChanged(
1096 branch.id, '~does/not/exist', '', *self.arbitrary_format_strings)
1097 self.assertIs(None, branch.stacked_on)
1098 self.assertTrue('~does/not/exist' in branch.mirror_status_message)
1099@@ -722,7 +631,7 @@
1100 # mirror_status_message.
1101 branch = self.factory.makeAnyBranch()
1102 removeSecurityProxy(branch).mirror_status_message = 'foo'
1103- self.branchfs.branchChanged(
1104+ self.codehosting_api.branchChanged(
1105 branch.id, '', '', *self.arbitrary_format_strings)
1106 self.assertIs(None, branch.mirror_status_message)
1107
1108@@ -731,7 +640,7 @@
1109 # "NoBranchWithID" is returned.
1110 unused_id = -1
1111 expected_fault = faults.NoBranchWithID(unused_id)
1112- received_fault = self.branchfs.branchChanged(
1113+ received_fault = self.codehosting_api.branchChanged(
1114 unused_id, '', '', *self.arbitrary_format_strings)
1115 self.assertEqual(
1116 (expected_fault.faultCode, expected_fault.faultString),
1117@@ -744,7 +653,7 @@
1118 branch = self.factory.makeAnyBranch()
1119 jobs = list(getUtility(IBranchScanJobSource).iterReady())
1120 self.assertEqual(0, len(jobs))
1121- self.branchfs.branchChanged(
1122+ self.codehosting_api.branchChanged(
1123 branch.id, '', 'rev1', *self.arbitrary_format_strings)
1124 jobs = list(getUtility(IBranchScanJobSource).iterReady())
1125 self.assertEqual(1, len(jobs))
1126@@ -756,14 +665,14 @@
1127 removeSecurityProxy(branch).last_mirrored_id = 'rev1'
1128 jobs = list(getUtility(IBranchScanJobSource).iterReady())
1129 self.assertEqual(0, len(jobs))
1130- self.branchfs.branchChanged(
1131+ self.codehosting_api.branchChanged(
1132 branch.id, '', 'rev1', *self.arbitrary_format_strings)
1133 jobs = list(getUtility(IBranchScanJobSource).iterReady())
1134 self.assertEqual(0, len(jobs))
1135
1136 def test_branchChanged_2a_format(self):
1137 branch = self.factory.makeAnyBranch()
1138- self.branchfs.branchChanged(
1139+ self.codehosting_api.branchChanged(
1140 branch.id, '', 'rev1', *self.getFormatStringsForFormatName('2a'))
1141 self.assertEqual(
1142 (ControlFormat.BZR_METADIR_1, BranchFormat.BZR_BRANCH_7,
1143@@ -773,7 +682,7 @@
1144
1145 def test_branchChanged_packs_format(self):
1146 branch = self.factory.makeAnyBranch()
1147- self.branchfs.branchChanged(
1148+ self.codehosting_api.branchChanged(
1149 branch.id, '', 'rev1',
1150 *self.getFormatStringsForFormatName('pack-0.92'))
1151 self.assertEqual(
1152@@ -784,7 +693,7 @@
1153
1154 def test_branchChanged_knits_format(self):
1155 branch = self.factory.makeAnyBranch()
1156- self.branchfs.branchChanged(
1157+ self.codehosting_api.branchChanged(
1158 branch.id, '', 'rev1',
1159 *self.getFormatStringsForFormatName('knit'))
1160 self.assertEqual(
1161@@ -795,21 +704,21 @@
1162
1163 def assertCannotTranslate(self, requester, path):
1164 """Assert that we cannot translate 'path'."""
1165- fault = self.branchfs.translatePath(requester.id, path)
1166+ fault = self.codehosting_api.translatePath(requester.id, path)
1167 self.assertEqual(faults.PathTranslationError(path), fault)
1168
1169 def assertNotFound(self, requester, path):
1170 """Assert that the given path cannot be found."""
1171 if requester not in [LAUNCHPAD_ANONYMOUS, LAUNCHPAD_SERVICES]:
1172 requester = requester.id
1173- fault = self.branchfs.translatePath(requester, path)
1174+ fault = self.codehosting_api.translatePath(requester, path)
1175 self.assertEqual(faults.PathTranslationError(path), fault)
1176
1177 def assertPermissionDenied(self, requester, path):
1178 """Assert that looking at the given path gives permission denied."""
1179 if requester not in [LAUNCHPAD_ANONYMOUS, LAUNCHPAD_SERVICES]:
1180 requester = requester.id
1181- fault = self.branchfs.translatePath(requester, path)
1182+ fault = self.codehosting_api.translatePath(requester, path)
1183 self.assertEqual(faults.PermissionDenied(), fault)
1184
1185 def _makeProductWithDevFocus(self, private=False):
1186@@ -837,14 +746,14 @@
1187 def test_translatePath_no_preceding_slash(self):
1188 requester = self.factory.makePerson()
1189 path = escape(u'invalid')
1190- fault = self.branchfs.translatePath(requester.id, path)
1191+ fault = self.codehosting_api.translatePath(requester.id, path)
1192 self.assertEqual(faults.InvalidPath(path), fault)
1193
1194 def test_translatePath_branch(self):
1195 requester = self.factory.makePerson()
1196 branch = self.factory.makeAnyBranch()
1197 path = escape(u'/%s' % branch.unique_name)
1198- translation = self.branchfs.translatePath(requester.id, path)
1199+ translation = self.codehosting_api.translatePath(requester.id, path)
1200 login(ANONYMOUS)
1201 self.assertEqual(
1202 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1203@@ -854,7 +763,7 @@
1204 requester = self.factory.makePerson()
1205 branch = self.factory.makeAnyBranch()
1206 path = escape(u'/%s/' % branch.unique_name)
1207- translation = self.branchfs.translatePath(requester.id, path)
1208+ translation = self.codehosting_api.translatePath(requester.id, path)
1209 login(ANONYMOUS)
1210 self.assertEqual(
1211 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1212@@ -864,7 +773,7 @@
1213 requester = self.factory.makePerson()
1214 branch = self.factory.makeAnyBranch()
1215 path = escape(u'/%s/child' % branch.unique_name)
1216- translation = self.branchfs.translatePath(requester.id, path)
1217+ translation = self.codehosting_api.translatePath(requester.id, path)
1218 login(ANONYMOUS)
1219 self.assertEqual(
1220 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, 'child'),
1221@@ -874,7 +783,7 @@
1222 requester = self.factory.makePerson()
1223 branch = self.factory.makeAnyBranch()
1224 path = escape(u'/%s/a/b' % branch.unique_name)
1225- translation = self.branchfs.translatePath(requester.id, path)
1226+ translation = self.codehosting_api.translatePath(requester.id, path)
1227 login(ANONYMOUS)
1228 self.assertEqual(
1229 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, 'a/b'),
1230@@ -888,7 +797,7 @@
1231 # escaped.
1232 self.assertNotEqual(escape(child_path), child_path.encode('utf-8'))
1233 path = escape(u'/%s/%s' % (branch.unique_name, child_path))
1234- translation = self.branchfs.translatePath(requester.id, path)
1235+ translation = self.codehosting_api.translatePath(requester.id, path)
1236 login(ANONYMOUS)
1237 self.assertEqual(
1238 (BRANCH_TRANSPORT,
1239@@ -925,7 +834,7 @@
1240 self.factory.makeAnyBranch(
1241 branch_type=BranchType.HOSTED, private=True, owner=requester))
1242 path = escape(u'/%s' % branch.unique_name)
1243- translation = self.branchfs.translatePath(requester.id, path)
1244+ translation = self.codehosting_api.translatePath(requester.id, path)
1245 login(ANONYMOUS)
1246 self.assertEqual(
1247 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': True}, ''),
1248@@ -946,7 +855,8 @@
1249 def test_translatePath_launchpad_services_private(self):
1250 branch = removeSecurityProxy(self.factory.makeAnyBranch(private=True))
1251 path = escape(u'/%s' % branch.unique_name)
1252- translation = self.branchfs.translatePath(LAUNCHPAD_SERVICES, path)
1253+ translation = self.codehosting_api.translatePath(
1254+ LAUNCHPAD_SERVICES, path)
1255 login(ANONYMOUS)
1256 self.assertEqual(
1257 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1258@@ -960,7 +870,8 @@
1259 def test_translatePath_anonymous_public_branch(self):
1260 branch = self.factory.makeAnyBranch()
1261 path = escape(u'/%s' % branch.unique_name)
1262- translation = self.branchfs.translatePath(LAUNCHPAD_ANONYMOUS, path)
1263+ translation = self.codehosting_api.translatePath(
1264+ LAUNCHPAD_ANONYMOUS, path)
1265 self.assertEqual(
1266 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1267 translation)
1268@@ -970,7 +881,7 @@
1269 branch = self.factory.makeAnyBranch(
1270 branch_type=BranchType.HOSTED, owner=requester)
1271 path = escape(u'/%s' % branch.unique_name)
1272- translation = self.branchfs.translatePath(requester.id, path)
1273+ translation = self.codehosting_api.translatePath(requester.id, path)
1274 login(ANONYMOUS)
1275 self.assertEqual(
1276 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': True}, ''),
1277@@ -982,7 +893,7 @@
1278 branch = self.factory.makeAnyBranch(
1279 branch_type=BranchType.HOSTED, owner=team)
1280 path = escape(u'/%s' % branch.unique_name)
1281- translation = self.branchfs.translatePath(requester.id, path)
1282+ translation = self.codehosting_api.translatePath(requester.id, path)
1283 login(ANONYMOUS)
1284 self.assertEqual(
1285 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': True}, ''),
1286@@ -994,7 +905,7 @@
1287 branch = self.factory.makeAnyBranch(
1288 branch_type=BranchType.HOSTED, owner=team)
1289 path = escape(u'/%s' % branch.unique_name)
1290- translation = self.branchfs.translatePath(requester.id, path)
1291+ translation = self.codehosting_api.translatePath(requester.id, path)
1292 login(ANONYMOUS)
1293 self.assertEqual(
1294 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1295@@ -1005,7 +916,7 @@
1296 branch = self.factory.makeAnyBranch(
1297 branch_type=BranchType.MIRRORED, owner=requester)
1298 path = escape(u'/%s' % branch.unique_name)
1299- translation = self.branchfs.translatePath(requester.id, path)
1300+ translation = self.codehosting_api.translatePath(requester.id, path)
1301 login(ANONYMOUS)
1302 self.assertEqual(
1303 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1304@@ -1016,7 +927,7 @@
1305 branch = self.factory.makeAnyBranch(
1306 branch_type=BranchType.IMPORTED, owner=requester)
1307 path = escape(u'/%s' % branch.unique_name)
1308- translation = self.branchfs.translatePath(requester.id, path)
1309+ translation = self.codehosting_api.translatePath(requester.id, path)
1310 login(ANONYMOUS)
1311 self.assertEqual(
1312 (BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1313@@ -1036,7 +947,7 @@
1314 requester = self.factory.makePerson()
1315 product, branch = self._makeProductWithDevFocus()
1316 path = escape(u'/~%s/%s/.bzr' % (requester.name, product.name))
1317- translation = self.branchfs.translatePath(requester.id, path)
1318+ translation = self.codehosting_api.translatePath(requester.id, path)
1319 login(ANONYMOUS)
1320 self.assertTranslationIsControlDirectory(
1321 translation,
1322@@ -1062,7 +973,7 @@
1323 branch = removeSecurityProxy(branch)
1324 requester = branch.owner
1325 path = escape(u'/~%s/%s/.bzr/' % (requester.name, product.name))
1326- translation = self.branchfs.translatePath(requester.id, path)
1327+ translation = self.codehosting_api.translatePath(requester.id, path)
1328 login(ANONYMOUS)
1329 self.assertTranslationIsControlDirectory(
1330 translation,
1331@@ -1074,7 +985,7 @@
1332 product, branch = self._makeProductWithDevFocus()
1333 owner = self.factory.makePerson()
1334 path = escape(u'/~%s/%s/.bzr' % (owner.name, product.name))
1335- translation = self.branchfs.translatePath(requester.id, path)
1336+ translation = self.codehosting_api.translatePath(requester.id, path)
1337 login(ANONYMOUS)
1338 self.assertTranslationIsControlDirectory(
1339 translation,
1340@@ -1100,7 +1011,7 @@
1341 self.assertIsNot(
1342 None, IBranchTarget(package).default_stacked_on_branch)
1343 path = '/~%s/%s/.bzr/' % (requester.name, package.path)
1344- translation = self.branchfs.translatePath(requester.id, path)
1345+ translation = self.codehosting_api.translatePath(requester.id, path)
1346 login(ANONYMOUS)
1347 self.assertTranslationIsControlDirectory(
1348 translation,
1349@@ -1108,6 +1019,89 @@
1350 trailing_path='.bzr')
1351
1352
1353+class AcquireBranchToPullTestsViaEndpoint(TestCaseWithFactory,
1354+ AcquireBranchToPullTests):
1355+ """Tests for `acquireBranchToPull` method of `ICodehostingAPI`."""
1356+
1357+ def setUp(self):
1358+ super(AcquireBranchToPullTestsViaEndpoint, self).setUp()
1359+ frontend = self.frontend()
1360+ self.codehosting_api = frontend.getCodehostingEndpoint()
1361+ self.factory = frontend.getLaunchpadObjectFactory()
1362+
1363+ def assertNoBranchIsAquired(self, *branch_types):
1364+ """See `AcquireBranchToPullTests`."""
1365+ branch_types = tuple(branch_type.name for branch_type in branch_types)
1366+ pull_info = self.codehosting_api.acquireBranchToPull(branch_types)
1367+ self.assertEqual((), pull_info)
1368+
1369+ def assertBranchIsAquired(self, branch, *branch_types):
1370+ """See `AcquireBranchToPullTests`."""
1371+ branch = removeSecurityProxy(branch)
1372+ branch_types = tuple(branch_type.name for branch_type in branch_types)
1373+ pull_info = self.codehosting_api.acquireBranchToPull(branch_types)
1374+ default_branch = branch.target.default_stacked_on_branch
1375+ if default_branch:
1376+ default_branch_name = default_branch
1377+ else:
1378+ default_branch_name = ''
1379+ self.assertEqual(
1380+ pull_info,
1381+ (branch.id, branch.getPullURL(), branch.unique_name,
1382+ default_branch_name, branch.branch_type.name))
1383+ self.assertIsNot(None, branch.last_mirror_attempt)
1384+ self.assertIs(None, branch.next_mirror_time)
1385+
1386+ def startMirroring(self, branch):
1387+ """See `AcquireBranchToPullTests`."""
1388+ self.codehosting_api.startMirroring(branch.id)
1389+
1390+ def test_branch_type_returned_mirrored(self):
1391+ branch = self.factory.makeAnyBranch(branch_type=BranchType.MIRRORED)
1392+ branch.requestMirror()
1393+ pull_info = self.codehosting_api.acquireBranchToPull(())
1394+ _, _, _, _, branch_type = pull_info
1395+ self.assertEqual('MIRRORED', branch_type)
1396+
1397+ def test_branch_type_returned_import(self):
1398+ branch = self.factory.makeAnyBranch(branch_type=BranchType.IMPORTED)
1399+ branch.requestMirror()
1400+ pull_info = self.codehosting_api.acquireBranchToPull(())
1401+ _, _, _, _, branch_type = pull_info
1402+ self.assertEqual('IMPORTED', branch_type)
1403+
1404+ def test_default_stacked_on_branch_returned(self):
1405+ branch = self.factory.makeProductBranch(
1406+ branch_type=BranchType.MIRRORED)
1407+ self.factory.enableDefaultStackingForProduct(branch.product)
1408+ branch.requestMirror()
1409+ pull_info = self.codehosting_api.acquireBranchToPull(())
1410+ _, _, _, default_stacked_on_branch, _ = pull_info
1411+ self.assertEqual(
1412+ default_stacked_on_branch,
1413+ '/' + branch.target.default_stacked_on_branch.unique_name)
1414+
1415+ def test_private_default_stacked_not_returned_for_mirrored_branch(self):
1416+ # We don't stack mirrored branches on a private default stacked on
1417+ # branch.
1418+ product = self.factory.makeProduct()
1419+ default_branch = self.factory.makeProductBranch(
1420+ product=product, private=True)
1421+ self.factory.enableDefaultStackingForProduct(product, default_branch)
1422+ mirrored_branch = self.factory.makeProductBranch(
1423+ branch_type=BranchType.MIRRORED, product=product)
1424+ mirrored_branch.requestMirror()
1425+ pull_info = self.codehosting_api.acquireBranchToPull(())
1426+ _, _, _, default_stacked_on_branch, _ = pull_info
1427+ self.assertEqual(
1428+ '', default_stacked_on_branch)
1429+
1430+ def test_unknown_branch_type_name_raises(self):
1431+ self.assertRaises(
1432+ UnknownBranchTypeError, self.codehosting_api.acquireBranchToPull,
1433+ ('NO_SUCH_TYPE',))
1434+
1435+
1436 class LaunchpadDatabaseFrontend:
1437 """A 'frontend' to Launchpad's branch services.
1438
1439@@ -1119,13 +1113,9 @@
1440 alternative implementations can be provided, see `InMemoryFrontend`.
1441 """
1442
1443- def getFilesystemEndpoint(self):
1444+ def getCodehostingEndpoint(self):
1445 """Return the branch filesystem endpoint for testing."""
1446- return BranchFileSystem(None, None)
1447-
1448- def getPullerEndpoint(self):
1449- """Return the branch puller endpoint for testing."""
1450- return BranchPuller(None, None)
1451+ return CodehostingAPI(None, None)
1452
1453 def getLaunchpadObjectFactory(self):
1454 """Return the Launchpad object factory for testing.
1455@@ -1148,13 +1138,13 @@
1456 return getUtility(IScriptActivitySet).getLastActivity(activity_name)
1457
1458
1459+
1460 def test_suite():
1461 loader = unittest.TestLoader()
1462 suite = unittest.TestSuite()
1463- puller_tests = unittest.TestSuite(
1464- [loader.loadTestsFromTestCase(BranchPullerTest),
1465- loader.loadTestsFromTestCase(AcquireBranchToPullTestsViaEndpoint),
1466- loader.loadTestsFromTestCase(BranchFileSystemTest),
1467+ endpoint_tests = unittest.TestSuite(
1468+ [loader.loadTestsFromTestCase(AcquireBranchToPullTestsViaEndpoint),
1469+ loader.loadTestsFromTestCase(CodehostingTest),
1470 ])
1471 scenarios = [
1472 ('db', {'frontend': LaunchpadDatabaseFrontend,
1473@@ -1162,6 +1152,6 @@
1474 ('inmemory', {'frontend': InMemoryFrontend,
1475 'layer': FunctionalLayer}),
1476 ]
1477- multiply_tests(puller_tests, scenarios, suite)
1478+ multiply_tests(endpoint_tests, scenarios, suite)
1479 suite.addTests(loader.loadTestsFromTestCase(TestRunWithLogin))
1480 return suite
1481
1482=== modified file 'lib/lp/codehosting/inmemory.py'
1483--- lib/lp/codehosting/inmemory.py 2010-04-27 02:11:16 +0000
1484+++ lib/lp/codehosting/inmemory.py 2010-04-27 02:11:35 +0000
1485@@ -449,10 +449,18 @@
1486 return branch
1487
1488
1489-class FakeBranchPuller:
1490+class FakeCodehosting:
1491
1492- def __init__(self, branch_set, script_activity_set):
1493+ def __init__(self, branch_set, person_set, product_set, distribution_set,
1494+ distroseries_set, sourcepackagename_set, factory,
1495+ script_activity_set):
1496 self._branch_set = branch_set
1497+ self._person_set = person_set
1498+ self._product_set = product_set
1499+ self._distribution_set = distribution_set
1500+ self._distroseries_set = distroseries_set
1501+ self._sourcepackagename_set = sourcepackagename_set
1502+ self._factory = factory
1503 self._script_activity_set = script_activity_set
1504
1505 def acquireBranchToPull(self, branch_type_names):
1506@@ -538,19 +546,6 @@
1507 return faults.NoSuchBranch(stacked_on_location)
1508 return True
1509
1510-
1511-class FakeBranchFilesystem:
1512-
1513- def __init__(self, branch_set, person_set, product_set, distribution_set,
1514- distroseries_set, sourcepackagename_set, factory):
1515- self._branch_set = branch_set
1516- self._person_set = person_set
1517- self._product_set = product_set
1518- self._distribution_set = distribution_set
1519- self._distroseries_set = distroseries_set
1520- self._sourcepackagename_set = sourcepackagename_set
1521- self._factory = factory
1522-
1523 def createBranch(self, requester_id, branch_path):
1524 if not branch_path.startswith('/'):
1525 return faults.InvalidPath(branch_path)
1526@@ -780,31 +775,22 @@
1527 self._branch_set, self._person_set, self._product_set,
1528 self._distribution_set, self._distroseries_set,
1529 self._sourcepackagename_set)
1530- self._puller = FakeBranchPuller(
1531- self._branch_set, self._script_activity_set)
1532- self._branchfs = FakeBranchFilesystem(
1533+ self._codehosting = FakeCodehosting(
1534 self._branch_set, self._person_set, self._product_set,
1535 self._distribution_set, self._distroseries_set,
1536- self._sourcepackagename_set, self._factory)
1537+ self._sourcepackagename_set, self._factory,
1538+ self._script_activity_set)
1539 sm = getSiteManager()
1540 sm.registerAdapter(fake_product_to_branch_target)
1541 sm.registerAdapter(fake_source_package_to_branch_target)
1542
1543- def getFilesystemEndpoint(self):
1544+ def getCodehostingEndpoint(self):
1545 """See `LaunchpadDatabaseFrontend`.
1546
1547 Return an in-memory implementation of IBranchFileSystem that passes
1548 the tests in `test_codehosting`.
1549 """
1550- return self._branchfs
1551-
1552- def getPullerEndpoint(self):
1553- """See `LaunchpadDatabaseFrontend`.
1554-
1555- Return an in-memory implementation of IBranchPuller that passes the
1556- tests in `test_codehosting`.
1557- """
1558- return self._puller
1559+ return self._codehosting
1560
1561 def getLaunchpadObjectFactory(self):
1562 """See `LaunchpadDatabaseFrontend`.
1563
1564=== modified file 'lib/lp/codehosting/puller/scheduler.py'
1565--- lib/lp/codehosting/puller/scheduler.py 2010-04-27 02:11:16 +0000
1566+++ lib/lp/codehosting/puller/scheduler.py 2010-04-27 02:11:35 +0000
1567@@ -296,7 +296,7 @@
1568 self.branch_type_name = branch_type_name
1569 self.default_stacked_on_url = default_stacked_on_url
1570 self.logger = logger
1571- self.branch_puller_endpoint = client
1572+ self.codehosting_endpoint = client
1573 self._available_oops_prefixes = available_oops_prefixes
1574
1575 @cachedproperty
1576@@ -348,7 +348,7 @@
1577 return deferred
1578
1579 def setStackedOn(self, stacked_on_location):
1580- deferred = self.branch_puller_endpoint.callRemote(
1581+ deferred = self.codehosting_endpoint.callRemote(
1582 'setStackedOn', self.branch_id, stacked_on_location)
1583 def no_such_branch(failure):
1584 # If there's no branch for stacked_on_location, then we just
1585@@ -365,7 +365,7 @@
1586 def mirrorFailed(self, reason, oops):
1587 self.logger.info('Recorded %s', oops)
1588 self.logger.info('Recorded failure: %s', str(reason))
1589- return self.branch_puller_endpoint.callRemote(
1590+ return self.codehosting_endpoint.callRemote(
1591 'mirrorFailed', self.branch_id, reason)
1592
1593 def mirrorSucceeded(self, revid_before, revid_after):
1594@@ -377,7 +377,7 @@
1595 'Successfully mirrored %s branch %d %s to %s to from rev %s to %s'
1596 ' (%s)', self.branch_type_name, self.branch_id, self.source_url,
1597 self.destination_url, revid_before, revid_after, was_noop)
1598- return self.branch_puller_endpoint.callRemote(
1599+ return self.codehosting_endpoint.callRemote(
1600 'mirrorComplete', self.branch_id, revid_after)
1601
1602 def log(self, message):
1603@@ -411,8 +411,8 @@
1604 branches.
1605 """
1606
1607- def __init__(self, branch_puller_endpoint, logger, branch_type_names):
1608- self.branch_puller_endpoint = branch_puller_endpoint
1609+ def __init__(self, codehosting_endpoint, logger, branch_type_names):
1610+ self.codehosting_endpoint = codehosting_endpoint
1611 self.logger = logger
1612 self.branch_type_names = branch_type_names
1613 self.actualLock = None
1614@@ -445,11 +445,11 @@
1615 master = PullerMaster(
1616 branch_id, pull_url, unique_name, branch_type_name,
1617 default_stacked_on_url, self.logger,
1618- self.branch_puller_endpoint, self.available_oops_prefixes)
1619+ self.codehosting_endpoint, self.available_oops_prefixes)
1620 return master.run
1621
1622 def _poll(self):
1623- deferred = self.branch_puller_endpoint.callRemote(
1624+ deferred = self.codehosting_endpoint.callRemote(
1625 'acquireBranchToPull', self.branch_type_names)
1626 deferred.addCallback(self._turnJobTupleIntoTask)
1627 return deferred
1628@@ -483,7 +483,7 @@
1629 """Record successful completion of the script."""
1630 started_tuple = tuple(date_started.utctimetuple())
1631 completed_tuple = tuple(date_completed.utctimetuple())
1632- return self.branch_puller_endpoint.callRemote(
1633+ return self.codehosting_endpoint.callRemote(
1634 'recordSuccess', self.name, socket.gethostname(), started_tuple,
1635 completed_tuple)
1636
1637
1638=== modified file 'lib/lp/codehosting/puller/tests/test_scheduler.py'
1639--- lib/lp/codehosting/puller/tests/test_scheduler.py 2010-04-27 02:11:16 +0000
1640+++ lib/lp/codehosting/puller/tests/test_scheduler.py 2010-04-27 02:11:35 +0000
1641@@ -40,7 +40,7 @@
1642 from lp.testing.factory import ObjectFactory
1643
1644
1645-class FakePullerEndpointProxy:
1646+class FakeCodehostingEndpointProxy:
1647
1648 def __init__(self):
1649 self.calls = []
1650@@ -81,7 +81,8 @@
1651
1652 def makeJobScheduler(self, branch_type_names=()):
1653 return scheduler.JobScheduler(
1654- FakePullerEndpointProxy(), logging.getLogger(), branch_type_names)
1655+ FakeCodehostingEndpointProxy(), logging.getLogger(),
1656+ branch_type_names)
1657
1658 def testManagerCreatesLocks(self):
1659 manager = self.makeJobScheduler()
1660@@ -105,7 +106,7 @@
1661 manager.run()
1662 self.assertEqual(
1663 [('acquireBranchToPull', ('MIRRORED',))],
1664- manager.branch_puller_endpoint.calls)
1665+ manager.codehosting_endpoint.calls)
1666
1667
1668 class TestPullerWireProtocol(TrialTestCase):
1669@@ -421,7 +422,7 @@
1670 layer = TwistedLayer
1671
1672 def setUp(self):
1673- self.status_client = FakePullerEndpointProxy()
1674+ self.status_client = FakeCodehostingEndpointProxy()
1675 self.arbitrary_branch_id = 1
1676 self.eventHandler = scheduler.PullerMaster(
1677 self.arbitrary_branch_id, 'arbitrary-source', 'arbitrary-dest',
1678@@ -528,7 +529,7 @@
1679 branch_type_name=branch_type_name,
1680 default_stacked_on_url=default_stacked_on_url,
1681 logger=logging.getLogger(),
1682- client=FakePullerEndpointProxy(),
1683+ client=FakeCodehostingEndpointProxy(),
1684 available_oops_prefixes=oops_prefixes)
1685
1686 @property
1687@@ -642,7 +643,7 @@
1688 branch_type=BranchType.MIRRORED, url=url).id
1689 self.layer.txn.commit()
1690 self.db_branch = getUtility(IBranchLookup).get(branch_id)
1691- self.client = FakePullerEndpointProxy()
1692+ self.client = FakeCodehostingEndpointProxy()
1693
1694 def run(self, result):
1695 # We want to use Trial's run() method so we can return Deferreds.
1696
1697=== modified file 'lib/lp/codehosting/sftp.py'
1698--- lib/lp/codehosting/sftp.py 2010-04-27 02:11:16 +0000
1699+++ lib/lp/codehosting/sftp.py 2010-04-27 02:11:35 +0000
1700@@ -244,7 +244,8 @@
1701 user_id = avatar.user_id
1702 branch_transport = _get_transport_for_dir(
1703 config.codehosting.mirrored_branches_root)
1704- server = LaunchpadServer(avatar.branchfs_proxy, user_id, branch_transport)
1705+ server = LaunchpadServer(
1706+ avatar.codehosting_proxy, user_id, branch_transport)
1707 server.start_server()
1708 transport = AsyncLaunchpadTransport(server, server.get_url())
1709 return TransportSFTPServer(transport)
1710
1711=== modified file 'lib/lp/codehosting/sshserver/daemon.py'
1712--- lib/lp/codehosting/sshserver/daemon.py 2010-04-15 15:27:30 +0000
1713+++ lib/lp/codehosting/sshserver/daemon.py 2010-04-27 02:11:35 +0000
1714@@ -45,13 +45,13 @@
1715 class CodehostingAvatar(LaunchpadAvatar):
1716 """An SSH avatar specific to codehosting.
1717
1718- :ivar branchfs_proxy: A Twisted XML-RPC client for the authserver. The
1719- server must implement `IBranchFileSystem`.
1720+ :ivar codehosting_proxy: A Twisted XML-RPC client for the private XML-RPC
1721+ server. The server must implement `ICodehostingAPI`.
1722 """
1723
1724- def __init__(self, user_dict, branchfs_proxy):
1725+ def __init__(self, user_dict, codehosting_proxy):
1726 LaunchpadAvatar.__init__(self, user_dict)
1727- self.branchfs_proxy = branchfs_proxy
1728+ self.codehosting_proxy = codehosting_proxy
1729
1730
1731 components.registerAdapter(launch_smart_server, CodehostingAvatar, ISession)
1732@@ -63,9 +63,9 @@
1733 class Realm:
1734 implements(IRealm)
1735
1736- def __init__(self, authentication_proxy, branchfs_proxy):
1737+ def __init__(self, authentication_proxy, codehosting_proxy):
1738 self.authentication_proxy = authentication_proxy
1739- self.branchfs_proxy = branchfs_proxy
1740+ self.codehosting_proxy = codehosting_proxy
1741
1742 def requestAvatar(self, avatar_id, mind, *interfaces):
1743 # Fetch the user's details from the authserver
1744@@ -74,15 +74,15 @@
1745
1746 # Once all those details are retrieved, we can construct the avatar.
1747 def got_user_dict(user_dict):
1748- avatar = CodehostingAvatar(user_dict, self.branchfs_proxy)
1749+ avatar = CodehostingAvatar(user_dict, self.codehosting_proxy)
1750 return interfaces[0], avatar, avatar.logout
1751
1752 return deferred.addCallback(got_user_dict)
1753
1754
1755-def get_portal(authentication_proxy, branchfs_proxy):
1756+def get_portal(authentication_proxy, codehosting_proxy):
1757 """Get a portal for connecting to Launchpad codehosting."""
1758- portal = Portal(Realm(authentication_proxy, branchfs_proxy))
1759+ portal = Portal(Realm(authentication_proxy, codehosting_proxy))
1760 portal.registerChecker(
1761 PublicKeyFromLaunchpadChecker(authentication_proxy))
1762 return portal
1763@@ -101,5 +101,5 @@
1764 """
1765 authentication_proxy = Proxy(
1766 config.codehosting.authentication_endpoint)
1767- branchfs_proxy = Proxy(config.codehosting.branchfs_endpoint)
1768- return get_portal(authentication_proxy, branchfs_proxy)
1769+ codehosting_proxy = Proxy(config.codehosting.codehosting_endpoint)
1770+ return get_portal(authentication_proxy, codehosting_proxy)
1771
1772=== modified file 'lib/lp/codehosting/tests/test_acceptance.py'
1773--- lib/lp/codehosting/tests/test_acceptance.py 2010-04-27 02:11:16 +0000
1774+++ lib/lp/codehosting/tests/test_acceptance.py 2010-04-27 02:11:35 +0000
1775@@ -230,14 +230,15 @@
1776 """
1777 authserver = xmlrpclib.ServerProxy(
1778 config.codehosting.authentication_endpoint)
1779- branchfs = xmlrpclib.ServerProxy(config.codehosting.branchfs_endpoint)
1780+ codehosting_api = xmlrpclib.ServerProxy(
1781+ config.codehosting.codehosting_endpoint)
1782 if creator is None:
1783 creator_id = authserver.getUserAndSSHKeys(user)['id']
1784 else:
1785 creator_id = authserver.getUserAndSSHKeys(creator)['id']
1786 if branch_root is None:
1787 branch_root = self.server._mirror_root
1788- branch_id = branchfs.createBranch(
1789+ branch_id = codehosting_api.createBranch(
1790 creator_id, '/~%s/%s/%s' % (user, product, branch))
1791 branch_url = 'file://' + os.path.abspath(
1792 os.path.join(branch_root, branch_id_to_path(branch_id)))
1793
1794=== modified file 'lib/lp/codehosting/tests/test_sftp.py'
1795--- lib/lp/codehosting/tests/test_sftp.py 2010-04-15 14:29:42 +0000
1796+++ lib/lp/codehosting/tests/test_sftp.py 2010-04-27 02:11:35 +0000
1797@@ -107,13 +107,13 @@
1798 TrialTestCase.setUp(self)
1799 frontend = InMemoryFrontend()
1800 self.factory = frontend.getLaunchpadObjectFactory()
1801- self.branchfs_endpoint = XMLRPCWrapper(
1802- frontend.getFilesystemEndpoint())
1803+ self.codehosting_endpoint = XMLRPCWrapper(
1804+ frontend.getCodehostingEndpoint())
1805
1806 def makeCodehostingAvatar(self):
1807 user = self.factory.makePerson()
1808 user_dict = dict(id=user.id, name=user.name)
1809- return CodehostingAvatar(user_dict, self.branchfs_endpoint)
1810+ return CodehostingAvatar(user_dict, self.codehosting_endpoint)
1811
1812 def test_canAdaptToSFTPServer(self):
1813 avatar = self.makeCodehostingAvatar()
1814
1815=== modified file 'lib/lp/codehosting/vfs/branchfs.py'
1816--- lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:11:16 +0000
1817+++ lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:11:35 +0000
1818@@ -68,8 +68,8 @@
1819 from bzrlib.bzrdir import BzrDir, BzrDirFormat
1820 from bzrlib.config import TransportConfig
1821 from bzrlib.errors import (
1822- NoSuchFile, NotBranchError, NotStacked, PermissionDenied,
1823- TransportNotPossible, UnstackableBranchFormat)
1824+ NoSuchFile, NotStacked, PermissionDenied, TransportNotPossible,
1825+ UnstackableBranchFormat)
1826 from bzrlib.plugins.loom.branch import LoomSupport
1827 from bzrlib.smart.request import jail_info
1828 from bzrlib.transport import get_transport
1829@@ -169,12 +169,12 @@
1830
1831 def get_scanner_server():
1832 """Get a Launchpad internal server for scanning branches."""
1833- proxy = xmlrpclib.ServerProxy(config.codehosting.branchfs_endpoint)
1834- branchfs_endpoint = BlockingProxy(proxy)
1835+ proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)
1836+ codehosting_endpoint = BlockingProxy(proxy)
1837 branch_transport = get_readonly_transport(
1838 get_transport(config.codehosting.internal_branch_by_id_root))
1839 return LaunchpadInternalServer(
1840- 'lp-mirrored:///', branchfs_endpoint, branch_transport)
1841+ 'lp-mirrored:///', codehosting_endpoint, branch_transport)
1842
1843
1844 def get_rw_server():
1845@@ -185,10 +185,10 @@
1846 """
1847 hosted_transport = get_chrooted_transport(
1848 config.codehosting.mirrored_branches_root, mkdir=True)
1849- proxy = xmlrpclib.ServerProxy(config.codehosting.branchfs_endpoint)
1850- branchfs_endpoint = BlockingProxy(proxy)
1851+ proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)
1852+ codehosting_endpoint = BlockingProxy(proxy)
1853 return LaunchpadInternalServer(
1854- 'lp-internal:///', branchfs_endpoint, hosted_transport)
1855+ 'lp-internal:///', codehosting_endpoint, hosted_transport)
1856
1857
1858 def get_multi_server(write_hosted=False, write_mirrored=False,
1859@@ -223,11 +223,11 @@
1860 if direct_database:
1861 make_server = DirectDatabaseLaunchpadServer
1862 else:
1863- proxy = xmlrpclib.ServerProxy(config.codehosting.branchfs_endpoint)
1864- branchfs_endpoint = BlockingProxy(proxy)
1865+ proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)
1866+ codehosting_endpoint = BlockingProxy(proxy)
1867 def make_server(scheme, transport):
1868 return LaunchpadInternalServer(
1869- scheme, branchfs_endpoint, transport)
1870+ scheme, codehosting_endpoint, transport)
1871 hosted_server = make_server('lp-hosted:///', hosted_transport)
1872 mirrored_server = make_server('lp-mirrored:///', mirrored_transport)
1873 return _MultiServer(hosted_server, mirrored_server)
1874@@ -367,39 +367,41 @@
1875
1876 For more information, see the module docstring.
1877
1878- :ivar _authserver: An object that has a method 'translatePath' that
1879+ :ivar _branchfs_client: An object that has a method 'translatePath' that
1880 returns a Deferred that fires information about how a path can be
1881 translated into a transport. See `IBranchFilesystem['translatePath']`.
1882
1883 :ivar _transport_dispatch: An `ITransportDispatch` provider used to
1884- convert the data from the authserver into an actual transport and
1885+ convert the data from the branchfs client into an actual transport and
1886 path on that transport.
1887 """
1888
1889- def __init__(self, scheme, authserver, user_id,
1890+ def __init__(self, scheme, codehosting_api, user_id,
1891 seen_new_branch_hook=None):
1892 """Construct a LaunchpadServer.
1893
1894 :param scheme: The URL scheme to use.
1895- :param authserver: An XML-RPC client that implements callRemote.
1896+ :param codehosting_api: An XML-RPC client that implements callRemote.
1897 :param user_id: The database ID for the user who is accessing
1898 branches.
1899 :param seen_new_branch_hook: A callable that will be called once for
1900 each branch accessed via this server.
1901 """
1902 AsyncVirtualServer.__init__(self, scheme)
1903- self._authserver = BranchFileSystemClient(
1904- authserver, user_id, seen_new_branch_hook=seen_new_branch_hook)
1905+ self._branchfs_client = BranchFileSystemClient(
1906+ codehosting_api, user_id,
1907+ seen_new_branch_hook=seen_new_branch_hook)
1908 self._is_start_server = False
1909
1910 def translateVirtualPath(self, virtual_url_fragment):
1911 """See `AsyncVirtualServer.translateVirtualPath`.
1912
1913- Call 'translatePath' on the authserver with the fragment and then use
1914- 'makeTransport' on the _transport_dispatch to translate that result
1915- into a transport and trailing path.
1916+ Call 'translatePath' on the branchfs client with the fragment and then
1917+ use 'makeTransport' on the _transport_dispatch to translate that
1918+ result into a transport and trailing path.
1919 """
1920- deferred = self._authserver.translatePath('/' + virtual_url_fragment)
1921+ deferred = self._branchfs_client.translatePath(
1922+ '/' + virtual_url_fragment)
1923
1924 def path_not_translated(failure):
1925 trap_fault(
1926@@ -426,19 +428,20 @@
1927 Intended for use with the branch puller and scanner.
1928 """
1929
1930- def __init__(self, scheme, authserver, branch_transport):
1931+ def __init__(self, scheme, codehosting_api, branch_transport):
1932 """Construct a `LaunchpadInternalServer`.
1933
1934 :param scheme: The URL scheme to use.
1935
1936- :param authserver: An object that provides a 'translatePath' method.
1937+ :param codehosting_api: An object that provides a 'translatePath'
1938+ method.
1939
1940 :param branch_transport: A Bazaar `Transport` that refers to an
1941 area where Launchpad branches are stored, generally either the
1942 hosted or mirrored areas.
1943 """
1944 super(LaunchpadInternalServer, self).__init__(
1945- scheme, authserver, LAUNCHPAD_SERVICES)
1946+ scheme, codehosting_api, LAUNCHPAD_SERVICES)
1947 self._transport_dispatch = BranchTransportDispatch(branch_transport)
1948
1949 def start_server(self):
1950@@ -564,13 +567,13 @@
1951
1952 asyncTransportFactory = AsyncLaunchpadTransport
1953
1954- def __init__(self, authserver, user_id, branch_transport,
1955+ def __init__(self, codehosting_api, user_id, branch_transport,
1956 seen_new_branch_hook=None):
1957 """Construct a `LaunchpadServer`.
1958
1959 See `_BaseLaunchpadServer` for more information.
1960
1961- :param authserver: An object that has 'createBranch' and
1962+ :param codehosting_api: An object that has 'createBranch' and
1963 'branchChanged' methods in addition to a 'translatePath' method.
1964 These methods should return Deferreds.
1965 XXX: JonathanLange 2008-11-19: Specify this interface better.
1966@@ -583,7 +586,7 @@
1967 """
1968 scheme = 'lp-%d:///' % id(self)
1969 super(LaunchpadServer, self).__init__(
1970- scheme, authserver, user_id, seen_new_branch_hook)
1971+ scheme, codehosting_api, user_id, seen_new_branch_hook)
1972 self._transport_dispatch = TransportDispatch(branch_transport)
1973
1974 def createBranch(self, virtual_url_fragment):
1975@@ -604,7 +607,7 @@
1976 that its creation is forbidden by a policy.
1977 :raise Fault: If the XML-RPC server raises errors.
1978 """
1979- deferred = self._authserver.createBranch(virtual_url_fragment)
1980+ deferred = self._branchfs_client.createBranch(virtual_url_fragment)
1981
1982 def translate_fault(failure):
1983 # We turn faults.NotFound into a PermissionDenied, even
1984@@ -667,7 +670,8 @@
1985 :param virtual_url_fragment: A url fragment that points to a path
1986 owned by a branch.
1987 """
1988- deferred = self._authserver.translatePath('/' + virtual_url_fragment)
1989+ deferred = self._branchfs_client.translatePath(
1990+ '/' + virtual_url_fragment)
1991
1992 def got_path_info((transport_type, data, trailing_path)):
1993 if transport_type != BRANCH_TRANSPORT:
1994@@ -693,7 +697,7 @@
1995 jail_info.transports.remove(transport)
1996 if stacked_on_url is None:
1997 stacked_on_url = ''
1998- return self._authserver.branchChanged(
1999+ return self._branchfs_client.branchChanged(
2000 data['id'], stacked_on_url, last_revision,
2001 control_string, branch_string, repository_string)
2002
2003@@ -703,29 +707,29 @@
2004 return deferred.addCallback(got_path_info).addErrback(log.err)
2005
2006
2007-def get_lp_server(user_id, branchfs_endpoint_url=None, branch_directory=None,
2008+def get_lp_server(user_id, codehosting_endpoint_url=None, branch_directory=None,
2009 seen_new_branch_hook=None):
2010 """Create a Launchpad server.
2011
2012 :param user_id: A unique database ID of the user whose branches are
2013 being served.
2014- :param branchfs_endpoint_url: URL for the branch file system end-point.
2015+ :param codehosting_endpoint_url: URL for the branch file system end-point.
2016 :param hosted_directory: Where the branches are uploaded to.
2017 :param mirror_directory: Where all Launchpad branches are mirrored.
2018 :param seen_new_branch_hook:
2019 :return: A `LaunchpadServer`.
2020 """
2021 # Get the defaults from the config.
2022- if branchfs_endpoint_url is None:
2023- branchfs_endpoint_url = config.codehosting.branchfs_endpoint
2024+ if codehosting_endpoint_url is None:
2025+ codehosting_endpoint_url = config.codehosting.codehosting_endpoint
2026 if branch_directory is None:
2027 branch_directory = config.codehosting.mirrored_branches_root
2028
2029 branch_url = urlutils.local_path_to_url(branch_directory)
2030- branchfs_client = xmlrpclib.ServerProxy(branchfs_endpoint_url)
2031+ codehosting_client = xmlrpclib.ServerProxy(codehosting_endpoint_url)
2032 branch_transport = get_chrooted_transport(branch_url)
2033 lp_server = LaunchpadServer(
2034- BlockingProxy(branchfs_client), user_id, branch_transport,
2035+ BlockingProxy(codehosting_client), user_id, branch_transport,
2036 seen_new_branch_hook)
2037 return lp_server
2038
2039
2040=== modified file 'lib/lp/codehosting/vfs/branchfsclient.py'
2041--- lib/lp/codehosting/vfs/branchfsclient.py 2010-04-27 02:11:16 +0000
2042+++ lib/lp/codehosting/vfs/branchfsclient.py 2010-04-27 02:11:35 +0000
2043@@ -34,20 +34,23 @@
2044
2045
2046 class BranchFileSystemClient:
2047- """Wrapper for the branch filesystem endpoint for a particular user.
2048-
2049- This wrapper caches the results of calls to translatePath in order to
2050+ """Wrapper for some methods of the codehosting endpoint.
2051+
2052+ Instances of this class wrap the methods of the codehosting endpoint
2053+ required by the VFS code, specialized for a particular user.
2054+
2055+ The wrapper also caches the results of calls to translatePath in order to
2056 avoid a large number of roundtrips. In the normal course of operation, our
2057 Bazaar transport translates virtual paths to real paths on disk using this
2058 client. It does this many, many times for a single Bazaar operation, so we
2059 cache the results here.
2060 """
2061
2062- def __init__(self, branchfs_endpoint, user_id, expiry_time=None,
2063+ def __init__(self, codehosting_endpoint, user_id, expiry_time=None,
2064 seen_new_branch_hook=None, _now=time.time):
2065- """Construct a caching branchfs_endpoint.
2066+ """Construct a caching codehosting_endpoint.
2067
2068- :param branchfs_endpoint: An XML-RPC proxy that implements callRemote.
2069+ :param codehosting_endpoint: An XML-RPC proxy that implements callRemote.
2070 :param user_id: The database ID of the user who will be making these
2071 requests. An integer.
2072 :param expiry_time: If supplied, only cache the results of
2073@@ -56,7 +59,7 @@
2074 :param seen_new_branch_hook: A callable that will be called with the
2075 unique_name of each new branch that is accessed.
2076 """
2077- self._branchfs_endpoint = branchfs_endpoint
2078+ self._codehosting_endpoint = codehosting_endpoint
2079 self._cache = {}
2080 self._user_id = user_id
2081 self.expiry_time = expiry_time
2082@@ -104,16 +107,16 @@
2083 def createBranch(self, branch_path):
2084 """Create a Launchpad `IBranch` in the database.
2085
2086- This raises any Faults that might be raised by the branchfs_endpoint's
2087- `createBranch` method, so for more information see
2088- `IBranchFileSystem.createBranch`.
2089+ This raises any Faults that might be raised by the
2090+ codehosting_endpoint's `createBranch` method, so for more information
2091+ see `IBranchFileSystem.createBranch`.
2092
2093 :param branch_path: The path to the branch to create.
2094 :return: A `Deferred` that fires the ID of the created branch.
2095 """
2096 return defer.maybeDeferred(
2097- self._branchfs_endpoint.callRemote, 'createBranch', self._user_id,
2098- branch_path)
2099+ self._codehosting_endpoint.callRemote, 'createBranch',
2100+ self._user_id, branch_path)
2101
2102 def branchChanged(self, branch_id, stacked_on_url, last_revision_id,
2103 control_string, branch_string, repository_string):
2104@@ -122,7 +125,7 @@
2105 :param branch_id: The database ID of the branch.
2106 """
2107 return defer.maybeDeferred(
2108- self._branchfs_endpoint.callRemote,
2109+ self._codehosting_endpoint.callRemote,
2110 'branchChanged', branch_id, stacked_on_url, last_revision_id,
2111 control_string, branch_string, repository_string)
2112
2113@@ -132,7 +135,7 @@
2114 return defer.succeed(self._getFromCache(path))
2115 except NotInCache:
2116 deferred = defer.maybeDeferred(
2117- self._branchfs_endpoint.callRemote,
2118+ self._codehosting_endpoint.callRemote,
2119 'translatePath', self._user_id, path)
2120 deferred.addCallback(self._addToCache, path)
2121 return deferred
2122
2123=== modified file 'lib/lp/codehosting/vfs/tests/test_branchfs.py'
2124--- lib/lp/codehosting/vfs/tests/test_branchfs.py 2010-04-27 02:11:16 +0000
2125+++ lib/lp/codehosting/vfs/tests/test_branchfs.py 2010-04-27 02:11:35 +0000
2126@@ -176,13 +176,13 @@
2127
2128 def setUp(self):
2129 frontend = InMemoryFrontend()
2130- self.authserver = frontend.getFilesystemEndpoint()
2131+ self.codehosting_api = frontend.getCodehostingEndpoint()
2132 self.factory = frontend.getLaunchpadObjectFactory()
2133 self.requester = self.factory.makePerson()
2134 self.server = self.getLaunchpadServer(
2135- self.authserver, self.requester.id)
2136+ self.codehosting_api, self.requester.id)
2137
2138- def getLaunchpadServer(self, authserver, user_id):
2139+ def getLaunchpadServer(self, codehosting_api, user_id):
2140 raise NotImplementedError(
2141 "Override this with a Launchpad server factory.")
2142
2143@@ -213,9 +213,9 @@
2144 BzrTestCase.setUp(self)
2145 MixinBaseLaunchpadServerTests.setUp(self)
2146
2147- def getLaunchpadServer(self, authserver, user_id):
2148+ def getLaunchpadServer(self, codehosting_api, user_id):
2149 return LaunchpadServer(
2150- XMLRPCWrapper(authserver), user_id, MemoryTransport())
2151+ XMLRPCWrapper(codehosting_api), user_id, MemoryTransport())
2152
2153 def test_translateControlPath(self):
2154 branch = self.factory.makeProductBranch(owner=self.requester)
2155@@ -342,9 +342,9 @@
2156 self.disable_directory_isolation()
2157 MixinBaseLaunchpadServerTests.setUp(self)
2158
2159- def getLaunchpadServer(self, authserver, user_id):
2160+ def getLaunchpadServer(self, codehosting_api, user_id):
2161 return LaunchpadInternalServer(
2162- 'lp-test:///', XMLRPCWrapper(authserver), MemoryTransport())
2163+ 'lp-test:///', XMLRPCWrapper(codehosting_api), MemoryTransport())
2164
2165
2166 class TestDirectDatabaseLaunchpadServer(TestCaseWithFactory, TrialTestCase,
2167@@ -472,11 +472,11 @@
2168 def setUp(self):
2169 frontend = InMemoryFrontend()
2170 self.factory = frontend.getLaunchpadObjectFactory()
2171- authserver = frontend.getFilesystemEndpoint()
2172+ codehosting_api = frontend.getCodehostingEndpoint()
2173 self.requester = self.factory.makePerson()
2174 self.backing_transport = MemoryTransport()
2175 self.server = self.getServer(
2176- authserver, self.requester.id, self.backing_transport)
2177+ codehosting_api, self.requester.id, self.backing_transport)
2178 self.server.start_server()
2179 self.addCleanup(self.server.stop_server)
2180
2181@@ -507,9 +507,9 @@
2182 """Call `function` and return an appropriate Deferred."""
2183 raise NotImplementedError
2184
2185- def getServer(self, authserver, user_id, backing_transport):
2186+ def getServer(self, codehosting_api, user_id, backing_transport):
2187 return LaunchpadServer(
2188- XMLRPCWrapper(authserver), user_id, backing_transport)
2189+ XMLRPCWrapper(codehosting_api), user_id, backing_transport)
2190
2191 def getTransport(self):
2192 """Return the transport to be tested."""
2193@@ -820,8 +820,8 @@
2194 self._branch_changed_log = []
2195 frontend = InMemoryFrontend()
2196 self.factory = frontend.getLaunchpadObjectFactory()
2197- self.authserver = frontend.getFilesystemEndpoint()
2198- self.authserver.branchChanged = self._replacement_branchChanged
2199+ self.codehosting_api = frontend.getCodehostingEndpoint()
2200+ self.codehosting_api.branchChanged = self._replacement_branchChanged
2201 self.requester = self.factory.makePerson()
2202 self.backing_transport = MemoryTransport()
2203 self.disable_directory_isolation()
2204@@ -835,7 +835,7 @@
2205 def get_server(self):
2206 if self._server is None:
2207 self._server = LaunchpadServer(
2208- XMLRPCWrapper(self.authserver), self.requester.id,
2209+ XMLRPCWrapper(self.codehosting_api), self.requester.id,
2210 self.backing_transport)
2211 self._server.start_server()
2212 self.addCleanup(self._server.stop_server)
2213@@ -987,7 +987,7 @@
2214 self._frontend = InMemoryFrontend()
2215 self.factory = self._frontend.getLaunchpadObjectFactory()
2216
2217- authserver = self._frontend.getFilesystemEndpoint()
2218+ codehosting_api = self._frontend.getCodehostingEndpoint()
2219 self.requester = self.factory.makePerson()
2220
2221 self.writable_branch = self.factory.makeAnyBranch(
2222@@ -997,7 +997,7 @@
2223 branch_type=BranchType.HOSTED).unique_name
2224
2225 self.lp_server = self._setUpLaunchpadServer(
2226- self.requester.id, authserver, backing_transport)
2227+ self.requester.id, codehosting_api, backing_transport)
2228 self.lp_transport = get_transport(self.lp_server.get_url())
2229 self.lp_transport.mkdir(os.path.dirname(self.writable_file))
2230 self.lp_transport.put_bytes(self.writable_file, 'Hello World!')
2231@@ -1008,9 +1008,9 @@
2232 self.addCleanup(memory_server.stop_server)
2233 return memory_server
2234
2235- def _setUpLaunchpadServer(self, user_id, authserver, backing_transport):
2236+ def _setUpLaunchpadServer(self, user_id, codehosting_api, backing_transport):
2237 server = LaunchpadServer(
2238- XMLRPCWrapper(authserver), user_id, backing_transport)
2239+ XMLRPCWrapper(codehosting_api), user_id, backing_transport)
2240 server.start_server()
2241 self.addCleanup(server.stop_server)
2242 return server
2243
2244=== modified file 'lib/lp/codehosting/vfs/tests/test_branchfsclient.py'
2245--- lib/lp/codehosting/vfs/tests/test_branchfsclient.py 2010-04-09 12:39:23 +0000
2246+++ lib/lp/codehosting/vfs/tests/test_branchfsclient.py 2010-04-27 02:11:35 +0000
2247@@ -25,7 +25,7 @@
2248 frontend = InMemoryFrontend()
2249 self.factory = frontend.getLaunchpadObjectFactory()
2250 self.user = self.factory.makePerson()
2251- self._xmlrpc_client = XMLRPCWrapper(frontend.getFilesystemEndpoint())
2252+ self._xmlrpc_client = XMLRPCWrapper(frontend.getCodehostingEndpoint())
2253 self.fake_time = FakeTime(12345)
2254
2255 def advanceTime(self, amount):
2256
2257=== modified file 'lib/lp/codehosting/vfs/tests/test_filesystem.py'
2258--- lib/lp/codehosting/vfs/tests/test_filesystem.py 2010-04-27 02:11:16 +0000
2259+++ lib/lp/codehosting/vfs/tests/test_filesystem.py 2010-04-27 02:11:35 +0000
2260@@ -30,7 +30,7 @@
2261 self.disable_directory_isolation()
2262 frontend = InMemoryFrontend()
2263 self.factory = frontend.getLaunchpadObjectFactory()
2264- endpoint = XMLRPCWrapper(frontend.getFilesystemEndpoint())
2265+ endpoint = XMLRPCWrapper(frontend.getCodehostingEndpoint())
2266 self.requester = self.factory.makePerson()
2267 self._server = LaunchpadServer(
2268 endpoint, self.requester.id, MemoryTransport())
2269
2270=== modified file 'lib/lp/codehosting/vfs/tests/test_transport.py'
2271--- lib/lp/codehosting/vfs/tests/test_transport.py 2010-01-20 02:00:32 +0000
2272+++ lib/lp/codehosting/vfs/tests/test_transport.py 2010-04-27 02:11:35 +0000
2273@@ -32,7 +32,7 @@
2274 an in-memory XML-RPC client and backed onto a LocalTransport.
2275 """
2276 frontend = InMemoryFrontend()
2277- branchfs = frontend.getFilesystemEndpoint()
2278+ branchfs = frontend.getCodehostingEndpoint()
2279 branch = frontend.getLaunchpadObjectFactory().makeAnyBranch()
2280 self._branch_path = branch.unique_name
2281 # XXX: JonathanLange bug=276972 2008-10-07: This should back on to a
2282
2283=== modified file 'scripts/update-stacked-on.py'
2284--- scripts/update-stacked-on.py 2010-02-16 15:25:52 +0000
2285+++ scripts/update-stacked-on.py 2010-04-27 02:11:35 +0000
2286@@ -39,7 +39,7 @@
2287
2288 def get_server(read_only):
2289 """Get a server that can write to both hosted and mirrored areas."""
2290- proxy = xmlrpclib.ServerProxy(config.codehosting.branchfs_endpoint)
2291+ proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)
2292 authserver = BlockingProxy(proxy)
2293 hosted_transport = get_chrooted_transport(
2294 config.codehosting.hosted_branches_root)