25
from bzrlib.hooks import Hooks
25
from bzrlib.hooks import HookPoint, Hooks
26
26
from bzrlib import (
29
transport as _mod_transport,
31
30
from bzrlib.lazy_import import lazy_import
32
31
lazy_import(globals(), """
33
32
from bzrlib.smart import medium
34
33
from bzrlib.transport import (
38
38
from bzrlib import (
103
103
# The URL that a commit done on the same machine as the server will
104
104
# have within the servers space. (e.g. file:///home/user/source)
105
105
# The URL that will be given to other hooks in the same process -
106
# the URL of the backing transport itself. (e.g. filtered-36195:///)
106
# the URL of the backing transport itself. (e.g. chroot+:///)
107
107
# We need all three because:
108
108
# * other machines see the first
109
109
# * local commits on this machine should be able to be mapped to
239
239
These are all empty initially, because by default nothing should get
242
Hooks.__init__(self, "bzrlib.smart.server", "SmartTCPServer.hooks")
243
self.add_hook('server_started',
243
self.create_hook(HookPoint('server_started',
244
244
"Called by the bzr server when it starts serving a directory. "
245
245
"server_started is called with (backing urls, public url), "
246
246
"where backing_url is a list of URLs giving the "
247
247
"server-specific directory locations, and public_url is the "
248
"public URL for the directory being served.", (0, 16))
249
self.add_hook('server_started_ex',
248
"public URL for the directory being served.", (0, 16), None))
249
self.create_hook(HookPoint('server_started_ex',
250
250
"Called by the bzr server when it starts serving a directory. "
251
251
"server_started is called with (backing_urls, server_obj).",
253
self.add_hook('server_stopped',
253
self.create_hook(HookPoint('server_stopped',
254
254
"Called by the bzr server when it stops serving a directory. "
255
255
"server_stopped is called with the same parameters as the "
256
"server_started hook: (backing_urls, public_url).", (0, 16))
256
"server_started hook: (backing_urls, public_url).", (0, 16), None))
258
258
SmartTCPServer.hooks = SmartServerHooks()
325
325
chroot_server = chroot.ChrootServer(transport)
326
326
chroot_server.start_server()
327
327
self.cleanups.append(chroot_server.stop_server)
328
transport = _mod_transport.get_transport(chroot_server.get_url())
328
transport = get_transport(chroot_server.get_url())
329
329
if self.base_path is not None:
330
330
# Decorate the server's backing transport with a filter that can
331
331
# expand homedirs.
332
332
expand_userdirs = self._make_expand_userdirs_filter(transport)
333
333
expand_userdirs.start_server()
334
334
self.cleanups.append(expand_userdirs.stop_server)
335
transport = _mod_transport.get_transport(expand_userdirs.get_url())
335
transport = get_transport(expand_userdirs.get_url())
336
336
self.transport = transport
338
338
def _make_smart_server(self, host, port, inet):