Rev 5613: (jelmer) Cope with IPv6 addresses in ``bzr serve`` (Jelmer Vernooij) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jan 14 23:41:16 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5613 [merge]
revision-id: pqm at pqm.ubuntu.com-20110114234114-r4hdusue691ekeg6
parent: pqm at pqm.ubuntu.com-20110114171823-5gx64sero62ag6r4
parent: jelmer at samba.org-20110114223645-6yk456ouj6kbhoqp
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2011-01-14 23:41:14 +0000
message:
(jelmer) Cope with IPv6 addresses in ``bzr serve`` (Jelmer Vernooij)
modified:
bzrlib/smart/server.py server.py-20061110062051-chzu10y32vx8gvur-1
bzrlib/tests/blackbox/test_serve.py test_serve.py-20060913064329-8t2pvmsikl4s3xhl-1
bzrlib/tests/test_server.py test_server.py-20100209163834-im1ozfuenfmqaa2m-1
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/smart/server.py'
--- a/bzrlib/smart/server.py 2010-07-01 15:25:41 +0000
+++ b/bzrlib/smart/server.py 2011-01-14 22:36:45 +0000
@@ -18,7 +18,6 @@
import errno
import os.path
-import select
import socket
import sys
import threading
@@ -27,7 +26,6 @@
from bzrlib import (
errors,
trace,
- transport,
)
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
@@ -178,7 +176,7 @@
def get_url(self):
"""Return the url of the server"""
- return "bzr://%s:%d/" % self._sockname
+ return "bzr://%s:%s/" % (self._sockname[0], self._sockname[1])
def serve_conn(self, conn, thread_name_suffix):
# For WIN32, where the timeout value from the listening socket
=== modified file 'bzrlib/tests/blackbox/test_serve.py'
--- a/bzrlib/tests/blackbox/test_serve.py 2011-01-10 22:20:12 +0000
+++ b/bzrlib/tests/blackbox/test_serve.py 2011-01-14 22:12:08 +0000
@@ -18,16 +18,12 @@
"""Tests of the bzr serve command."""
import os
-import os.path
import signal
-import subprocess
-import sys
import thread
import threading
from bzrlib import (
builtins,
- debug,
errors,
osutils,
revision as _mod_revision,
@@ -37,11 +33,13 @@
from bzrlib.branch import Branch
from bzrlib.bzrdir import BzrDir
from bzrlib.smart import client, medium
-from bzrlib.smart.server import BzrServerFactory, SmartTCPServer
+from bzrlib.smart.server import (
+ BzrServerFactory,
+ SmartTCPServer,
+ )
from bzrlib.tests import (
TestCaseWithMemoryTransport,
TestCaseWithTransport,
- TestSkipped,
)
from bzrlib.trace import mutter
from bzrlib.transport import remote
@@ -53,9 +51,9 @@
*func_args, **func_kwargs):
"""Run 'bzr serve', and run the given func in a thread once the server
has started.
-
+
When 'func' terminates, the server will be terminated too.
-
+
Returns stdout and stderr.
"""
# install hook
@@ -164,7 +162,7 @@
url = 'bzr://localhost:%d/' % port
self.permit_url(url)
return process, url
-
+
def test_bzr_serve_quiet(self):
self.make_branch('.')
args = ['--port', 'localhost:0', '--quiet']
@@ -334,4 +332,3 @@
self.assertEqual(base_url, self.bzr_serve_transport.base)
self.assertEqual(base_dir,
server_maker.get_base_path(self.bzr_serve_transport))
-
=== modified file 'bzrlib/tests/test_server.py'
--- a/bzrlib/tests/test_server.py 2011-01-12 01:01:53 +0000
+++ b/bzrlib/tests/test_server.py 2011-01-14 22:36:45 +0000
@@ -694,8 +694,6 @@
server.SmartTCPServer.__init__(self, backing_transport,
root_client_path)
def serve(self):
- # FIXME: No test are exercising the hooks for the test server
- # -- vila 20100618
self.run_server_started_hooks()
try:
TestingThreadingTCPServer.serve(self)
@@ -803,7 +801,3 @@
"""Get a backing transport from a server we are decorating."""
url = 'readonly+' + backing_transport_server.get_url()
return transport.get_transport(url)
-
-
-
-
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py 2011-01-14 17:18:23 +0000
+++ b/bzrlib/tests/test_smart.py 2011-01-14 23:41:14 +0000
@@ -41,6 +41,7 @@
repository as smart_repo,
packrepository as smart_packrepo,
request as smart_req,
+ server,
vfs,
)
from bzrlib.tests import test_server
@@ -1939,3 +1940,50 @@
smart_repo.SmartServerRepositoryUnlock)
self.assertHandlerEqual('Transport.is_readonly',
smart_req.SmartServerIsReadonly)
+
+
+class SmartTCPServerHookTests(tests.TestCaseWithMemoryTransport):
+ """Tests for SmartTCPServer hooks."""
+
+ def setUp(self):
+ super(SmartTCPServerHookTests, self).setUp()
+ self.server = server.SmartTCPServer(self.get_transport())
+
+ def test_run_server_started_hooks(self):
+ """Test the server started hooks get fired properly."""
+ started_calls = []
+ server.SmartTCPServer.hooks.install_named_hook('server_started',
+ lambda backing_urls, url: started_calls.append((backing_urls, url)),
+ None)
+ started_ex_calls = []
+ server.SmartTCPServer.hooks.install_named_hook('server_started_ex',
+ lambda backing_urls, url: started_ex_calls.append((backing_urls, url)),
+ None)
+ self.server._sockname = ('example.com', 42)
+ self.server.run_server_started_hooks()
+ self.assertEquals(started_calls,
+ [([self.get_transport().base], 'bzr://example.com:42/')])
+ self.assertEquals(started_ex_calls,
+ [([self.get_transport().base], self.server)])
+
+ def test_run_server_started_hooks_ipv6(self):
+ """Test that socknames can contain 4-tuples."""
+ self.server._sockname = ('::', 42, 0, 0)
+ started_calls = []
+ server.SmartTCPServer.hooks.install_named_hook('server_started',
+ lambda backing_urls, url: started_calls.append((backing_urls, url)),
+ None)
+ self.server.run_server_started_hooks()
+ self.assertEquals(started_calls,
+ [([self.get_transport().base], 'bzr://:::42/')])
+
+ def test_run_server_stopped_hooks(self):
+ """Test the server stopped hooks."""
+ self.server._sockname = ('example.com', 42)
+ stopped_calls = []
+ server.SmartTCPServer.hooks.install_named_hook('server_stopped',
+ lambda backing_urls, url: stopped_calls.append((backing_urls, url)),
+ None)
+ self.server.run_server_stopped_hooks()
+ self.assertEquals(stopped_calls,
+ [([self.get_transport().base], 'bzr://example.com:42/')])
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-01-14 05:34:20 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-01-14 21:24:14 +0000
@@ -32,6 +32,9 @@
.. Fixes for situations where bzr would previously crash or give incorrect
or undesirable results.
+* ``bzr serve`` no longer crashes when a server_started hook is installed and IPv6
+ support is available on the system. (Jelmer Vernooij, #293697)
+
Documentation
*************
More information about the bazaar-commits
mailing list