[PATCH 6 of 6] chgserver: replace SocketServer with mercurial.socketserver

Jun Wu quark at fb.com
Sun May 8 20:06:25 EDT 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1462477512 -3600
#      Thu May 05 20:45:12 2016 +0100
# Node ID 97e00ae27fcb57afa5d2a155bdabfc06821ee97a
# Parent  1700e9299ac9d56bc3f540ccd2497d8b360f0ce4
chgserver: replace SocketServer with mercurial.socketserver

Since we have our own socketserver module, use it for chgserver.

Notes about hgweb:

I had replaced socketserver in hgweb. While it looked straightforward,
Python 2.6 made it non-trivial:

  - BaseHTTPServer imports SocketServer, which is not patched.
    This can be worked around by modifying sys.modules before importing
    BaseHTTPServer:

      sys.modules['SocketServer'] = mercurial.socketserver

  - HTTPS issue.
    When running test-https.t, I got:

      File "hg/mercurial/hgweb/__init__.py", line 86, in run
        self.httpd.serve_forever()
      File "hg/mercurial/socketserver.py", line 298, in serve_forever
        self._handle_request_noblock()
      File "hg/mercurial/socketserver.py", line 372, in _handle_request_noblock
        request, client_address = self.get_request()
      File "hg/mercurial/socketserver.py", line 549, in get_request
        return self.socket.accept()
      File "/usr/lib64/python2.6/ssl.py", line 317, in accept
        raise e
      SSLError: [Errno 8] _ssl.c:492: EOF occurred in violation of protocol

    A quick search (http://stackoverflow.com/questions/14102416) shows
    patching Python's "ssl" module may solve the issue.

This is going to be too many and ugly. It only affects Python 2.6 anyway.
It seems not worth the effort so I will leave hgweb as is for now.

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -40,7 +40,6 @@
 
 from __future__ import absolute_import
 
-import SocketServer
 import errno
 import gc
 import inspect
@@ -63,6 +62,7 @@
     error,
     extensions,
     osutil,
+    socketserver as SocketServer,
     util,
 )
 


More information about the Mercurial-devel mailing list