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