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

login
register
mail settings
Submitter Jun Wu
Date May 9, 2016, 12:06 a.m.
Message ID <97e00ae27fcb57afa5d2.1462752385@x1c>
Download mbox | patch
Permalink /patch/14981/
State Changes Requested
Headers show

Comments

Jun Wu - May 9, 2016, 12:06 a.m.
# HG changeset patch
# User Jun Wu <quark@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.
Augie Fackler - May 11, 2016, 2:03 a.m.
On Mon, May 09, 2016 at 01:06:25AM +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1462477512 -3600
> #      Thu May 05 20:45:12 2016 +0100
> # Node ID 97e00ae27fcb57afa5d2a155bdabfc06821ee97a
> # Parent  1700e9299ac9d56bc3f540ccd2497d8b360f0ce4
> chgserver: replace SocketServer with mercurial.socketserver

Same aliasing comment on that. Other than those nitpicks, I'm pretty
happy with where this is going, even if the need for it is somewhat
tragic. Thanks!

Patch

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,
 )