~ian-clatworthy/bzr/faster-log-file

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-26 08:48:51 UTC
  • mfrom: (4370.4.7 serve-protocol)
  • Revision ID: pqm@pqm.ubuntu.com-20090526084851-z5v419bk4ni21res
(Jelmer) Add registry for the 'bzr serve' protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
307
307
        return transport.get_transport(url)
308
308
 
309
309
 
 
310
def serve_bzr(transport, host=None, port=None, inet=False):
 
311
    from bzrlib import lockdir, ui
 
312
    from bzrlib.transport import get_transport
 
313
    from bzrlib.transport.chroot import ChrootServer
 
314
    chroot_server = ChrootServer(transport)
 
315
    chroot_server.setUp()
 
316
    t = get_transport(chroot_server.get_url())
 
317
    if inet:
 
318
        smart_server = medium.SmartServerPipeStreamMedium(
 
319
            sys.stdin, sys.stdout, transport)
 
320
    else:
 
321
        if host is None:
 
322
            host = medium.BZR_DEFAULT_INTERFACE
 
323
        if port is None:
 
324
            port = medium.BZR_DEFAULT_PORT
 
325
        smart_server = SmartTCPServer(
 
326
            transport, host=host, port=port)
 
327
        trace.note('listening on port: %s' % smart_server.port)
 
328
    # For the duration of this server, no UI output is permitted. note
 
329
    # that this may cause problems with blackbox tests. This should be
 
330
    # changed with care though, as we dont want to use bandwidth sending
 
331
    # progress over stderr to smart server clients!
 
332
    old_factory = ui.ui_factory
 
333
    old_lockdir_timeout = lockdir._DEFAULT_TIMEOUT_SECONDS
 
334
    try:
 
335
        ui.ui_factory = ui.SilentUIFactory()
 
336
        lockdir._DEFAULT_TIMEOUT_SECONDS = 0
 
337
        smart_server.serve()
 
338
    finally:
 
339
        ui.ui_factory = old_factory
 
340
        lockdir._DEFAULT_TIMEOUT_SECONDS = old_lockdir_timeout
 
341