~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

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