Show More
@@ -333,6 +333,7 b' pypats = [' | |||
|
333 | 333 | (r'^import cPickle', "don't use cPickle, use util.pickle"), |
|
334 | 334 | (r'^import pickle', "don't use pickle, use util.pickle"), |
|
335 | 335 | (r'^import httplib', "don't use httplib, use util.httplib"), |
|
336 | (r'^import BaseHTTPServer', "use util.httpserver instead"), | |
|
336 | 337 | (r'\.next\(\)', "don't use .next(), use next(...)"), |
|
337 | 338 | |
|
338 | 339 | # rules depending on implementation of repquote() |
@@ -8,11 +8,14 b'' | |||
|
8 | 8 | |
|
9 | 9 | from __future__ import absolute_import |
|
10 | 10 | |
|
11 | import BaseHTTPServer | |
|
12 | 11 | import errno |
|
13 | 12 | import mimetypes |
|
14 | 13 | import os |
|
15 | 14 | |
|
15 | from .. import util | |
|
16 | ||
|
17 | httpserver = util.httpserver | |
|
18 | ||
|
16 | 19 | HTTP_OK = 200 |
|
17 | 20 | HTTP_NOT_MODIFIED = 304 |
|
18 | 21 | HTTP_BAD_REQUEST = 400 |
@@ -107,7 +110,7 b' class continuereader(object):' | |||
|
107 | 110 | raise AttributeError |
|
108 | 111 | |
|
109 | 112 | def _statusmessage(code): |
|
110 |
responses = |
|
|
113 | responses = httpserver.basehttprequesthandler.responses | |
|
111 | 114 | return responses.get(code, ('Error', 'Unknown error'))[0] |
|
112 | 115 | |
|
113 | 116 | def statusmessage(code, message=None): |
@@ -8,7 +8,6 b'' | |||
|
8 | 8 | |
|
9 | 9 | from __future__ import absolute_import |
|
10 | 10 | |
|
11 | import BaseHTTPServer | |
|
12 | 11 | import errno |
|
13 | 12 | import os |
|
14 | 13 | import socket |
@@ -22,6 +21,7 b' from .. import (' | |||
|
22 | 21 | util, |
|
23 | 22 | ) |
|
24 | 23 | |
|
24 | httpservermod = util.httpserver | |
|
25 | 25 | socketserver = util.socketserver |
|
26 | 26 | urlerr = util.urlerr |
|
27 | 27 | urlreq = util.urlreq |
@@ -53,7 +53,7 b' class _error_logger(object):' | |||
|
53 | 53 | for msg in seq: |
|
54 | 54 | self.handler.log_error("HG error: %s", msg) |
|
55 | 55 | |
|
56 |
class _httprequesthandler( |
|
|
56 | class _httprequesthandler(httpservermod.basehttprequesthandler): | |
|
57 | 57 | |
|
58 | 58 | url_scheme = 'http' |
|
59 | 59 | |
@@ -64,7 +64,7 b' class _httprequesthandler(BaseHTTPServer' | |||
|
64 | 64 | |
|
65 | 65 | def __init__(self, *args, **kargs): |
|
66 | 66 | self.protocol_version = 'HTTP/1.1' |
|
67 |
|
|
|
67 | httpservermod.basehttprequesthandler.__init__(self, *args, **kargs) | |
|
68 | 68 | |
|
69 | 69 | def _log_any(self, fp, format, *args): |
|
70 | 70 | fp.write("%s - - [%s] %s\n" % (self.client_address[0], |
@@ -263,14 +263,14 b' def openlog(opt, default):' | |||
|
263 | 263 | return open(opt, 'a') |
|
264 | 264 | return default |
|
265 | 265 | |
|
266 |
class MercurialHTTPServer(object, _mixin, |
|
|
266 | class MercurialHTTPServer(object, _mixin, httpservermod.httpserver): | |
|
267 | 267 | |
|
268 | 268 | # SO_REUSEADDR has broken semantics on windows |
|
269 | 269 | if os.name == 'nt': |
|
270 | 270 | allow_reuse_address = 0 |
|
271 | 271 | |
|
272 | 272 | def __init__(self, ui, app, addr, handler, **kwargs): |
|
273 |
|
|
|
273 | httpservermod.httpserver.__init__(self, addr, handler, **kwargs) | |
|
274 | 274 | self.daemon_threads = True |
|
275 | 275 | self.application = app |
|
276 | 276 |
@@ -76,9 +76,13 b' def _alias(alias, origin, items):' | |||
|
76 | 76 | except AttributeError: |
|
77 | 77 | pass |
|
78 | 78 | |
|
79 | httpserver = _pycompatstub() | |
|
79 | 80 | urlreq = _pycompatstub() |
|
80 | 81 | urlerr = _pycompatstub() |
|
81 | 82 | try: |
|
83 | import BaseHTTPServer | |
|
84 | import CGIHTTPServer | |
|
85 | import SimpleHTTPServer | |
|
82 | 86 | import urllib2 |
|
83 | 87 | import urllib |
|
84 | 88 | _alias(urlreq, urllib, ( |
@@ -116,6 +120,16 b' try:' | |||
|
116 | 120 | "HTTPError", |
|
117 | 121 | "URLError", |
|
118 | 122 | )) |
|
123 | _alias(httpserver, BaseHTTPServer, ( | |
|
124 | "HTTPServer", | |
|
125 | "BaseHTTPRequestHandler", | |
|
126 | )) | |
|
127 | _alias(httpserver, SimpleHTTPServer, ( | |
|
128 | "SimpleHTTPRequestHandler", | |
|
129 | )) | |
|
130 | _alias(httpserver, CGIHTTPServer, ( | |
|
131 | "CGIHTTPRequestHandler", | |
|
132 | )) | |
|
119 | 133 | |
|
120 | 134 | except ImportError: |
|
121 | 135 | import urllib.request |
@@ -151,6 +165,13 b' except ImportError:' | |||
|
151 | 165 | "HTTPError", |
|
152 | 166 | "URLError", |
|
153 | 167 | )) |
|
168 | import http.server | |
|
169 | _alias(httpserver, http.server, ( | |
|
170 | "HTTPServer", | |
|
171 | "BaseHTTPRequestHandler", | |
|
172 | "SimpleHTTPRequestHandler", | |
|
173 | "CGIHTTPRequestHandler", | |
|
174 | )) | |
|
154 | 175 | |
|
155 | 176 | try: |
|
156 | 177 | xrange |
@@ -48,6 +48,7 b' from . import (' | |||
|
48 | 48 | for attr in ( |
|
49 | 49 | 'empty', |
|
50 | 50 | 'httplib', |
|
51 | 'httpserver', | |
|
51 | 52 | 'pickle', |
|
52 | 53 | 'queue', |
|
53 | 54 | 'urlerr', |
@@ -6,24 +6,24 b' from __future__ import absolute_import' | |||
|
6 | 6 | Small and dumb HTTP server for use in tests. |
|
7 | 7 | """ |
|
8 | 8 | |
|
9 | import BaseHTTPServer | |
|
10 | import SimpleHTTPServer | |
|
11 | 9 | import optparse |
|
12 | 10 | import signal |
|
13 | 11 | import sys |
|
14 | 12 | |
|
15 | 13 | from mercurial import ( |
|
16 | 14 | cmdutil, |
|
15 | util, | |
|
17 | 16 | ) |
|
18 | 17 | |
|
18 | httpserver = util.httpserver | |
|
19 | 19 | OptionParser = optparse.OptionParser |
|
20 | 20 | |
|
21 | 21 | class simplehttpservice(object): |
|
22 | 22 | def __init__(self, host, port): |
|
23 | 23 | self.address = (host, port) |
|
24 | 24 | def init(self): |
|
25 |
self.httpd = |
|
|
26 |
self.address, |
|
|
25 | self.httpd = httpserver.httpserver( | |
|
26 | self.address, httpserver.simplehttprequesthandler) | |
|
27 | 27 | def run(self): |
|
28 | 28 | self.httpd.serve_forever() |
|
29 | 29 |
@@ -110,12 +110,12 b'' | |||
|
110 | 110 | mercurial/hbisect.py: error importing: <TypeError> str expected, not bytes (error at i18n.py:*) (glob) |
|
111 | 111 | mercurial/help.py: error importing: <TypeError> str expected, not bytes (error at i18n.py:*) (glob) |
|
112 | 112 | mercurial/hg.py: error importing: <TypeError> str expected, not bytes (error at i18n.py:*) (glob) |
|
113 |
mercurial/hgweb/common.py: error importing module: < |
|
|
113 | mercurial/hgweb/common.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) | |
|
114 | 114 | mercurial/hgweb/hgweb_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) |
|
115 | 115 | mercurial/hgweb/hgwebdir_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) |
|
116 | 116 | mercurial/hgweb/protocol.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) |
|
117 | 117 | mercurial/hgweb/request.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) |
|
118 |
mercurial/hgweb/server.py: error importing module: < |
|
|
118 | mercurial/hgweb/server.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) | |
|
119 | 119 | mercurial/hgweb/webcommands.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) |
|
120 | 120 | mercurial/hgweb/webutil.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) |
|
121 | 121 | mercurial/hgweb/wsgicgi.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob) |
@@ -136,8 +136,8 b'' | |||
|
136 | 136 | mercurial/patch.py: error importing: <TypeError> '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) |
|
137 | 137 | mercurial/pathutil.py: error importing: <TypeError> '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) |
|
138 | 138 | mercurial/peer.py: error importing: <TypeError> '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) |
|
139 |
mercurial/pure/mpatch.py: error importing module: < |
|
|
140 |
mercurial/pure/parsers.py: error importing module: < |
|
|
139 | mercurial/pure/mpatch.py: error importing module: <AttributeError> 'VendorImporter' object has no attribute 'find_spec' (line *) (glob) | |
|
140 | mercurial/pure/parsers.py: error importing module: <AttributeError> 'VendorImporter' object has no attribute 'find_spec' (line *) (glob) | |
|
141 | 141 | mercurial/pushkey.py: error importing: <TypeError> '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) |
|
142 | 142 | mercurial/pvec.py: error importing: <TypeError> '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) |
|
143 | 143 | mercurial/registrar.py: error importing: <TypeError> '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) |
@@ -14,7 +14,6 b' Any help will be greatly appreciated. ' | |||
|
14 | 14 | |
|
15 | 15 | __version__ = "0.2.1" |
|
16 | 16 | |
|
17 | import BaseHTTPServer | |
|
18 | 17 | import optparse |
|
19 | 18 | import os |
|
20 | 19 | import select |
@@ -23,11 +22,12 b' import sys' | |||
|
23 | 22 | |
|
24 | 23 | from mercurial import util |
|
25 | 24 | |
|
25 | httpserver = util.httpserver | |
|
26 | 26 | urlparse = util.urlparse |
|
27 | 27 | socketserver = util.socketserver |
|
28 | 28 | |
|
29 |
class ProxyHandler ( |
|
|
30 |
__base = |
|
|
29 | class ProxyHandler (httpserver.basehttprequesthandler): | |
|
30 | __base = httpserver.basehttprequesthandler | |
|
31 | 31 | __base_handle = __base.handle |
|
32 | 32 | |
|
33 | 33 | server_version = "TinyHTTPProxy/" + __version__ |
@@ -137,9 +137,9 b' class ProxyHandler (BaseHTTPServer.BaseH' | |||
|
137 | 137 | do_DELETE = do_GET |
|
138 | 138 | |
|
139 | 139 | class ThreadingHTTPServer (socketserver.ThreadingMixIn, |
|
140 |
|
|
|
140 | httpserver.httpserver): | |
|
141 | 141 | def __init__(self, *args, **kwargs): |
|
142 |
|
|
|
142 | httpserver.httpserver.__init__(self, *args, **kwargs) | |
|
143 | 143 | a = open("proxy.pid", "w") |
|
144 | 144 | a.write(str(os.getpid()) + "\n") |
|
145 | 145 | a.close() |
General Comments 0
You need to be logged in to leave comments.
Login now