~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Martin
  • Date: 2011-05-21 16:29:38 UTC
  • mto: This revision was merged to the branch mainline in revision 5907.
  • Revision ID: gzlist@googlemail.com-20110521162938-1vrw3hp0197l3vrl
Add tests for non-ascii conflict serialisation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
256
            "server_started hook: (backing_urls, public_url).", (0, 16))
257
 
        self.add_hook('server_exception',
258
 
            "Called by the bzr server when an exception occurs. "
259
 
            "server_exception is called with the sys.exc_info() tuple "
260
 
            "return true for the hook if the exception has been handled, "
261
 
            "in which case the server will exit normally.", (2, 4))
262
257
 
263
258
SmartTCPServer.hooks = SmartServerHooks()
264
259
 
330
325
        chroot_server = chroot.ChrootServer(transport)
331
326
        chroot_server.start_server()
332
327
        self.cleanups.append(chroot_server.stop_server)
333
 
        transport = _mod_transport.get_transport_from_url(chroot_server.get_url())
 
328
        transport = _mod_transport.get_transport(chroot_server.get_url())
334
329
        if self.base_path is not None:
335
330
            # Decorate the server's backing transport with a filter that can
336
331
            # expand homedirs.
337
332
            expand_userdirs = self._make_expand_userdirs_filter(transport)
338
333
            expand_userdirs.start_server()
339
334
            self.cleanups.append(expand_userdirs.stop_server)
340
 
            transport = _mod_transport.get_transport_from_url(expand_userdirs.get_url())
 
335
            transport = _mod_transport.get_transport(expand_userdirs.get_url())
341
336
        self.transport = transport
342
337
 
343
338
    def _make_smart_server(self, host, port, inet):
378
373
        for cleanup in reversed(self.cleanups):
379
374
            cleanup()
380
375
 
 
376
 
381
377
def serve_bzr(transport, host=None, port=None, inet=False):
382
378
    """This is the default implementation of 'bzr serve'.
383
379
    
389
385
    try:
390
386
        bzr_server.set_up(transport, host, port, inet)
391
387
        bzr_server.smart_server.serve()
392
 
    except:
393
 
        hook_caught_exception = False
394
 
        for hook in SmartTCPServer.hooks['server_exception']:
395
 
            hook_caught_exception = hook(sys.exc_info())
396
 
        if not hook_caught_exception:
397
 
            raise
398
388
    finally:
399
389
        bzr_server.tear_down()
 
390