~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Gordon Tyler
  • Date: 2011-01-21 23:51:15 UTC
  • mto: This revision was merged to the branch mainline in revision 5632.
  • Revision ID: gordon@doxxx.net-20110121235115-9sdqamejot1h0481
Replace usage of format function from python 2.6 with our own very simple formatting function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import sys
23
23
import threading
24
24
 
25
 
from bzrlib.hooks import Hooks
 
25
from bzrlib.hooks import HookPoint, Hooks
26
26
from bzrlib import (
27
27
    errors,
28
28
    trace,
29
 
    transport as _mod_transport,
30
29
)
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 (
35
34
    chroot,
 
35
    get_transport,
36
36
    pathfilter,
37
37
    )
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
240
240
        notified.
241
241
        """
242
 
        Hooks.__init__(self, "bzrlib.smart.server", "SmartTCPServer.hooks")
243
 
        self.add_hook('server_started',
 
242
        Hooks.__init__(self)
 
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).",
252
 
            (1, 17))
253
 
        self.add_hook('server_stopped',
 
252
            (1, 17), None))
 
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))
257
257
 
258
258
SmartTCPServer.hooks = SmartServerHooks()
259
259
 
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
337
337
 
338
338
    def _make_smart_server(self, host, port, inet):