def test_only_wraps_once(self): # get_readonly_transport just returns the given transport if its # already readonly. transport = MemoryTransport() readonly_transport = get_readonly_transport(transport) double_readonly = get_readonly_transport(readonly_transport) self.assertIs(readonly_transport, double_readonly)
def __init__(self, rw_transport): self._rw_dispatch = BranchTransportDispatch(rw_transport) self._ro_dispatch = BranchTransportDispatch(get_readonly_transport(rw_transport)) self._transport_factories = { BRANCH_TRANSPORT: self._makeBranchTransport, CONTROL_TRANSPORT: self._makeControlTransport, }
def __init__(self, rw_transport): self._rw_dispatch = BranchTransportDispatch(rw_transport) self._ro_dispatch = BranchTransportDispatch( get_readonly_transport(rw_transport)) self._transport_factories = { BRANCH_TRANSPORT: self._makeBranchTransport, CONTROL_TRANSPORT: self._makeControlTransport, }
def get_ro_server(): """Get a Launchpad internal server for scanning branches.""" proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) codehosting_endpoint = DeferredBlockingProxy(proxy) branch_transport = get_readonly_transport( get_transport(config.codehosting.internal_branch_by_id_root)) return LaunchpadInternalServer('lp-internal:///', codehosting_endpoint, branch_transport)
def _makeControlTransport(self, default_stack_on, trailing_path=None): """Make a transport that points to a control directory. A control directory is a .bzr directory containing a 'control.conf' file. This is used to specify configuration for branches created underneath the directory that contains the control directory. :param default_stack_on: The default stacked-on branch URL for branches that respect this control directory. If empty, then we'll return an empty memory transport. :return: A read-only `MemoryTransport` containing a working BzrDir, configured to use the given default stacked-on location. """ memory_server = MemoryServer() memory_server.start_server() transport = get_transport(memory_server.get_url()) if default_stack_on == "": return transport format = BzrDirFormat.get_default_format() bzrdir = format.initialize_on_transport(transport) bzrdir.get_config().set_default_stack_on(urlutils.unescape(default_stack_on)) return get_readonly_transport(transport)
def _makeControlTransport(self, default_stack_on, trailing_path=None): """Make a transport that points to a control directory. A control directory is a .bzr directory containing a 'control.conf' file. This is used to specify configuration for branches created underneath the directory that contains the control directory. :param default_stack_on: The default stacked-on branch URL for branches that respect this control directory. If empty, then we'll return an empty memory transport. :return: A read-only `MemoryTransport` containing a working BzrDir, configured to use the given default stacked-on location. """ memory_server = MemoryServer() memory_server.start_server() transport = get_transport(memory_server.get_url()) if default_stack_on == '': return transport format = BzrDirFormat.get_default_format() bzrdir = format.initialize_on_transport(transport) bzrdir.get_config().set_default_stack_on( urlutils.unescape(default_stack_on)) return get_readonly_transport(transport)
def get_ro_server(): """Get a Launchpad internal server for scanning branches.""" proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) codehosting_endpoint = DeferredBlockingProxy(proxy) branch_transport = get_readonly_transport(get_transport(config.codehosting.internal_branch_by_id_root)) return LaunchpadInternalServer("lp-internal:///", codehosting_endpoint, branch_transport)
def test_makes_readonly_transport(self): # get_readonly_transport wraps a transport so that its readonly. transport = MemoryTransport() self.assertEqual(False, transport.is_readonly()) readonly_transport = get_readonly_transport(transport) self.assertEqual(True, readonly_transport.is_readonly())