216
214
"where backing_url is a list of URLs giving the "
217
215
"server-specific directory locations, and public_url is the "
218
216
"public URL for the directory being served.", (0, 16), None))
219
self.create_hook(HookPoint('server_started_ex',
220
"Called by the bzr server when it starts serving a directory. "
221
"server_started is called with (backing_urls, server_obj).",
223
217
self.create_hook(HookPoint('server_stopped',
224
218
"Called by the bzr server when it stops serving a directory. "
225
219
"server_stopped is called with the same parameters as the "
313
307
return transport.get_transport(url)
316
def serve_bzr(transport, host=None, port=None, inet=False):
317
from bzrlib import lockdir, ui
318
from bzrlib.transport import get_transport
319
from bzrlib.transport.chroot import ChrootServer
320
chroot_server = ChrootServer(transport)
321
chroot_server.setUp()
322
transport = get_transport(chroot_server.get_url())
324
smart_server = medium.SmartServerPipeStreamMedium(
325
sys.stdin, sys.stdout, transport)
328
host = medium.BZR_DEFAULT_INTERFACE
330
port = medium.BZR_DEFAULT_PORT
331
smart_server = SmartTCPServer(transport, host=host, port=port)
332
trace.note('listening on port: %s' % smart_server.port)
333
# For the duration of this server, no UI output is permitted. note
334
# that this may cause problems with blackbox tests. This should be
335
# changed with care though, as we dont want to use bandwidth sending
336
# progress over stderr to smart server clients!
337
old_factory = ui.ui_factory
338
old_lockdir_timeout = lockdir._DEFAULT_TIMEOUT_SECONDS
340
ui.ui_factory = ui.SilentUIFactory()
341
lockdir._DEFAULT_TIMEOUT_SECONDS = 0
344
ui.ui_factory = old_factory
345
lockdir._DEFAULT_TIMEOUT_SECONDS = old_lockdir_timeout