Show More
@@ -19,7 +19,7 b'' | |||||
19 |
|
19 | |||
20 | #ifdef __SUNPRO_C |
|
20 | #ifdef __SUNPRO_C | |
21 | # define inline |
|
21 | # define inline | |
22 |
#endif |
|
22 | #endif | |
23 |
|
23 | |||
24 | #ifdef _WIN32 |
|
24 | #ifdef _WIN32 | |
25 | #ifdef _MSC_VER |
|
25 | #ifdef _MSC_VER |
@@ -548,7 +548,7 b' def help_(ui, name=None, with_version=Fa' | |||||
548 | """show help for a command, extension, or list of commands |
|
548 | """show help for a command, extension, or list of commands | |
549 |
|
549 | |||
550 | With no arguments, print a list of commands and short help. |
|
550 | With no arguments, print a list of commands and short help. | |
551 |
|
551 | |||
552 | Given a command name, print help for that command. |
|
552 | Given a command name, print help for that command. | |
553 |
|
553 | |||
554 | Given an extension name, print help for that extension, and the |
|
554 | Given an extension name, print help for that extension, and the | |
@@ -579,7 +579,7 b' def help_(ui, name=None, with_version=Fa' | |||||
579 | # options |
|
579 | # options | |
580 | if i[1]: |
|
580 | if i[1]: | |
581 | option_lists.append(("options", i[1])) |
|
581 | option_lists.append(("options", i[1])) | |
582 |
|
582 | |||
583 | def helplist(select=None): |
|
583 | def helplist(select=None): | |
584 | h = {} |
|
584 | h = {} | |
585 | cmds = {} |
|
585 | cmds = {} | |
@@ -3300,7 +3300,7 b' def findext(name):' | |||||
3300 | if k.endswith('.' + name) or v == name: |
|
3300 | if k.endswith('.' + name) or v == name: | |
3301 | return sys.modules[v] |
|
3301 | return sys.modules[v] | |
3302 | raise KeyError(name) |
|
3302 | raise KeyError(name) | |
3303 |
|
3303 | |||
3304 | def dispatch(args): |
|
3304 | def dispatch(args): | |
3305 | for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
|
3305 | for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': | |
3306 | num = getattr(signal, name, None) |
|
3306 | num = getattr(signal, name, None) |
@@ -88,7 +88,7 b' def clone(ui, source, dest=None, pull=Fa' | |||||
88 |
|
88 | |||
89 | If an exception is raised, the partly cloned/updated destination |
|
89 | If an exception is raised, the partly cloned/updated destination | |
90 | repository will be deleted. |
|
90 | repository will be deleted. | |
91 |
|
91 | |||
92 | Keyword arguments: |
|
92 | Keyword arguments: | |
93 |
|
93 | |||
94 | dest: URL of destination repository to create (defaults to base |
|
94 | dest: URL of destination repository to create (defaults to base |
@@ -129,7 +129,7 b' class _hgwebhandler(object, BaseHTTPServ' | |||||
129 | self.length = int(h[1]) |
|
129 | self.length = int(h[1]) | |
130 | # The value of the Connection header is a list of case-insensitive |
|
130 | # The value of the Connection header is a list of case-insensitive | |
131 | # tokens separated by commas and optional whitespace. |
|
131 | # tokens separated by commas and optional whitespace. | |
132 |
if 'close' in [token.strip().lower() for token in |
|
132 | if 'close' in [token.strip().lower() for token in | |
133 | self.headers.get('connection', '').split(',')]: |
|
133 | self.headers.get('connection', '').split(',')]: | |
134 | should_close = True |
|
134 | should_close = True | |
135 | if should_close: |
|
135 | if should_close: |
@@ -9,9 +9,9 b'' | |||||
9 | # Lesser General Public License for more details. |
|
9 | # Lesser General Public License for more details. | |
10 | # |
|
10 | # | |
11 | # You should have received a copy of the GNU Lesser General Public |
|
11 | # You should have received a copy of the GNU Lesser General Public | |
12 |
# License along with this library; if not, write to the |
|
12 | # License along with this library; if not, write to the | |
13 |
# Free Software Foundation, Inc., |
|
13 | # Free Software Foundation, Inc., | |
14 |
# 59 Temple Place, Suite 330, |
|
14 | # 59 Temple Place, Suite 330, | |
15 | # Boston, MA 02111-1307 USA |
|
15 | # Boston, MA 02111-1307 USA | |
16 |
|
16 | |||
17 | # This file is part of urlgrabber, a high-level cross-protocol url-grabber |
|
17 | # This file is part of urlgrabber, a high-level cross-protocol url-grabber | |
@@ -24,7 +24,7 b'' | |||||
24 | >>> keepalive_handler = HTTPHandler() |
|
24 | >>> keepalive_handler = HTTPHandler() | |
25 | >>> opener = urllib2.build_opener(keepalive_handler) |
|
25 | >>> opener = urllib2.build_opener(keepalive_handler) | |
26 | >>> urllib2.install_opener(opener) |
|
26 | >>> urllib2.install_opener(opener) | |
27 |
>>> |
|
27 | >>> | |
28 | >>> fo = urllib2.urlopen('http://www.python.org') |
|
28 | >>> fo = urllib2.urlopen('http://www.python.org') | |
29 |
|
29 | |||
30 | If a connection to a given host is requested, and all of the existing |
|
30 | If a connection to a given host is requested, and all of the existing | |
@@ -111,7 +111,7 b' DEBUG = None' | |||||
111 | import sys |
|
111 | import sys | |
112 | if sys.version_info < (2, 4): HANDLE_ERRORS = 1 |
|
112 | if sys.version_info < (2, 4): HANDLE_ERRORS = 1 | |
113 | else: HANDLE_ERRORS = 0 |
|
113 | else: HANDLE_ERRORS = 0 | |
114 |
|
114 | |||
115 | class ConnectionManager: |
|
115 | class ConnectionManager: | |
116 | """ |
|
116 | """ | |
117 | The connection manager must be able to: |
|
117 | The connection manager must be able to: | |
@@ -151,7 +151,7 b' class ConnectionManager:' | |||||
151 | def set_ready(self, connection, ready): |
|
151 | def set_ready(self, connection, ready): | |
152 | try: self._readymap[connection] = ready |
|
152 | try: self._readymap[connection] = ready | |
153 | except KeyError: pass |
|
153 | except KeyError: pass | |
154 |
|
154 | |||
155 | def get_ready_conn(self, host): |
|
155 | def get_ready_conn(self, host): | |
156 | conn = None |
|
156 | conn = None | |
157 | self._lock.acquire() |
|
157 | self._lock.acquire() | |
@@ -175,7 +175,7 b' class ConnectionManager:' | |||||
175 | class HTTPHandler(urllib2.HTTPHandler): |
|
175 | class HTTPHandler(urllib2.HTTPHandler): | |
176 | def __init__(self): |
|
176 | def __init__(self): | |
177 | self._cm = ConnectionManager() |
|
177 | self._cm = ConnectionManager() | |
178 |
|
178 | |||
179 | #### Connection Management |
|
179 | #### Connection Management | |
180 | def open_connections(self): |
|
180 | def open_connections(self): | |
181 | """return a list of connected hosts and the number of connections |
|
181 | """return a list of connected hosts and the number of connections | |
@@ -189,14 +189,14 b' class HTTPHandler(urllib2.HTTPHandler):' | |||||
189 | for h in self._cm.get_all(host): |
|
189 | for h in self._cm.get_all(host): | |
190 | self._cm.remove(h) |
|
190 | self._cm.remove(h) | |
191 | h.close() |
|
191 | h.close() | |
192 |
|
192 | |||
193 | def close_all(self): |
|
193 | def close_all(self): | |
194 | """close all open connections""" |
|
194 | """close all open connections""" | |
195 | for host, conns in self._cm.get_all().items(): |
|
195 | for host, conns in self._cm.get_all().items(): | |
196 | for h in conns: |
|
196 | for h in conns: | |
197 | self._cm.remove(h) |
|
197 | self._cm.remove(h) | |
198 | h.close() |
|
198 | h.close() | |
199 |
|
199 | |||
200 | def _request_closed(self, request, host, connection): |
|
200 | def _request_closed(self, request, host, connection): | |
201 | """tells us that this request is now closed and the the |
|
201 | """tells us that this request is now closed and the the | |
202 | connection is ready for another request""" |
|
202 | connection is ready for another request""" | |
@@ -205,7 +205,7 b' class HTTPHandler(urllib2.HTTPHandler):' | |||||
205 | def _remove_connection(self, host, connection, close=0): |
|
205 | def _remove_connection(self, host, connection, close=0): | |
206 | if close: connection.close() |
|
206 | if close: connection.close() | |
207 | self._cm.remove(connection) |
|
207 | self._cm.remove(connection) | |
208 |
|
208 | |||
209 | #### Transaction Execution |
|
209 | #### Transaction Execution | |
210 | def http_open(self, req): |
|
210 | def http_open(self, req): | |
211 | return self.do_open(HTTPConnection, req) |
|
211 | return self.do_open(HTTPConnection, req) | |
@@ -239,7 +239,7 b' class HTTPHandler(urllib2.HTTPHandler):' | |||||
239 | r = h.getresponse() |
|
239 | r = h.getresponse() | |
240 | except (socket.error, httplib.HTTPException), err: |
|
240 | except (socket.error, httplib.HTTPException), err: | |
241 | raise urllib2.URLError(err) |
|
241 | raise urllib2.URLError(err) | |
242 |
|
242 | |||
243 | # if not a persistent connection, don't try to reuse it |
|
243 | # if not a persistent connection, don't try to reuse it | |
244 | if r.will_close: self._cm.remove(h) |
|
244 | if r.will_close: self._cm.remove(h) | |
245 |
|
245 | |||
@@ -251,7 +251,7 b' class HTTPHandler(urllib2.HTTPHandler):' | |||||
251 | r.code = r.status |
|
251 | r.code = r.status | |
252 | r.headers = r.msg |
|
252 | r.headers = r.msg | |
253 | r.msg = r.reason |
|
253 | r.msg = r.reason | |
254 |
|
254 | |||
255 | if r.status == 200 or not HANDLE_ERRORS: |
|
255 | if r.status == 200 or not HANDLE_ERRORS: | |
256 | return r |
|
256 | return r | |
257 | else: |
|
257 | else: | |
@@ -287,7 +287,7 b' class HTTPHandler(urllib2.HTTPHandler):' | |||||
287 | self._cm.remove(h) |
|
287 | self._cm.remove(h) | |
288 | h.close() |
|
288 | h.close() | |
289 | raise |
|
289 | raise | |
290 |
|
290 | |||
291 | if r is None or r.version == 9: |
|
291 | if r is None or r.version == 9: | |
292 | # httplib falls back to assuming HTTP 0.9 if it gets a |
|
292 | # httplib falls back to assuming HTTP 0.9 if it gets a | |
293 | # bad header back. This is most likely to happen if |
|
293 | # bad header back. This is most likely to happen if | |
@@ -342,7 +342,7 b' class HTTPResponse(httplib.HTTPResponse)' | |||||
342 | # although read() never adds to the buffer. |
|
342 | # although read() never adds to the buffer. | |
343 | # Both readline and readlines have been stolen with almost no |
|
343 | # Both readline and readlines have been stolen with almost no | |
344 | # modification from socket.py |
|
344 | # modification from socket.py | |
345 |
|
345 | |||
346 |
|
346 | |||
347 | def __init__(self, sock, debuglevel=0, strict=0, method=None): |
|
347 | def __init__(self, sock, debuglevel=0, strict=0, method=None): | |
348 | if method: # the httplib in python 2.3 uses the method arg |
|
348 | if method: # the httplib in python 2.3 uses the method arg | |
@@ -371,7 +371,7 b' class HTTPResponse(httplib.HTTPResponse)' | |||||
371 | def close_connection(self): |
|
371 | def close_connection(self): | |
372 | self._handler._remove_connection(self._host, self._connection, close=1) |
|
372 | self._handler._remove_connection(self._host, self._connection, close=1) | |
373 | self.close() |
|
373 | self.close() | |
374 |
|
374 | |||
375 | def info(self): |
|
375 | def info(self): | |
376 | return self.headers |
|
376 | return self.headers | |
377 |
|
377 | |||
@@ -425,7 +425,7 b' class HTTPResponse(httplib.HTTPResponse)' | |||||
425 | class HTTPConnection(httplib.HTTPConnection): |
|
425 | class HTTPConnection(httplib.HTTPConnection): | |
426 | # use the modified response class |
|
426 | # use the modified response class | |
427 | response_class = HTTPResponse |
|
427 | response_class = HTTPResponse | |
428 |
|
428 | |||
429 | ######################################################################### |
|
429 | ######################################################################### | |
430 | ##### TEST FUNCTIONS |
|
430 | ##### TEST FUNCTIONS | |
431 | ######################################################################### |
|
431 | ######################################################################### | |
@@ -459,7 +459,7 b' def error_handler(url):' | |||||
459 | def continuity(url): |
|
459 | def continuity(url): | |
460 | import md5 |
|
460 | import md5 | |
461 | format = '%25s: %s' |
|
461 | format = '%25s: %s' | |
462 |
|
462 | |||
463 | # first fetch the file with the normal http handler |
|
463 | # first fetch the file with the normal http handler | |
464 | opener = urllib2.build_opener() |
|
464 | opener = urllib2.build_opener() | |
465 | urllib2.install_opener(opener) |
|
465 | urllib2.install_opener(opener) | |
@@ -506,7 +506,7 b' def comp(N, url):' | |||||
506 | t2 = fetch(N, url) |
|
506 | t2 = fetch(N, url) | |
507 | print ' TIME: %.3f s' % t2 |
|
507 | print ' TIME: %.3f s' % t2 | |
508 | print ' improvement factor: %.2f' % (t1/t2, ) |
|
508 | print ' improvement factor: %.2f' % (t1/t2, ) | |
509 |
|
509 | |||
510 | def fetch(N, url, delay=0): |
|
510 | def fetch(N, url, delay=0): | |
511 | import time |
|
511 | import time | |
512 | lens = [] |
|
512 | lens = [] | |
@@ -538,7 +538,7 b' def test_timeout(url):' | |||||
538 | fo = urllib2.urlopen(url) |
|
538 | fo = urllib2.urlopen(url) | |
539 | data1 = fo.read() |
|
539 | data1 = fo.read() | |
540 | fo.close() |
|
540 | fo.close() | |
541 |
|
541 | |||
542 | i = 20 |
|
542 | i = 20 | |
543 | print " waiting %i seconds for the server to close the connection" % i |
|
543 | print " waiting %i seconds for the server to close the connection" % i | |
544 | while i > 0: |
|
544 | while i > 0: | |
@@ -560,7 +560,7 b' def test_timeout(url):' | |||||
560 |
|
560 | |||
561 | DEBUG = dbbackup |
|
561 | DEBUG = dbbackup | |
562 |
|
562 | |||
563 |
|
563 | |||
564 | def test(url, N=10): |
|
564 | def test(url, N=10): | |
565 | print "checking error hander (do this on a non-200)" |
|
565 | print "checking error hander (do this on a non-200)" | |
566 | try: error_handler(url) |
|
566 | try: error_handler(url) | |
@@ -576,7 +576,7 b' def test(url, N=10):' | |||||
576 |
|
576 | |||
577 | print "performing dropped-connection check" |
|
577 | print "performing dropped-connection check" | |
578 | test_timeout(url) |
|
578 | test_timeout(url) | |
579 |
|
579 | |||
580 | if __name__ == '__main__': |
|
580 | if __name__ == '__main__': | |
581 | import time |
|
581 | import time | |
582 | import sys |
|
582 | import sys |
@@ -17,12 +17,12 b' import string' | |||||
17 | sys.modules['mercurial.demandload'] = sys.modules[__name__] |
|
17 | sys.modules['mercurial.demandload'] = sys.modules[__name__] | |
18 |
|
18 | |||
19 | # Requiredmodules contains the modules imported by demandload. |
|
19 | # Requiredmodules contains the modules imported by demandload. | |
20 |
# Please note that demandload can be invoked before the |
|
20 | # Please note that demandload can be invoked before the | |
21 | # mercurial.packagescan.scan method is invoked in case a mercurial |
|
21 | # mercurial.packagescan.scan method is invoked in case a mercurial | |
22 | # module is imported. |
|
22 | # module is imported. | |
23 |
requiredmodules = {} |
|
23 | requiredmodules = {} | |
24 | def demandload(scope, modules): |
|
24 | def demandload(scope, modules): | |
25 |
""" fake demandload function that collects the required modules |
|
25 | """ fake demandload function that collects the required modules | |
26 | foo import foo |
|
26 | foo import foo | |
27 | foo bar import foo, bar |
|
27 | foo bar import foo, bar | |
28 | foo.bar import foo.bar |
|
28 | foo.bar import foo.bar | |
@@ -49,7 +49,7 b' def demandload(scope, modules):' | |||||
49 | scope[mn] = mod |
|
49 | scope[mn] = mod | |
50 | requiredmodules[mod.__name__] = 1 |
|
50 | requiredmodules[mod.__name__] = 1 | |
51 | if len(comp) == i: break |
|
51 | if len(comp) == i: break | |
52 |
mod = getattr(mod,comp[i]) |
|
52 | mod = getattr(mod,comp[i]) | |
53 | mn = string.join(comp[:i+1],'.') |
|
53 | mn = string.join(comp[:i+1],'.') | |
54 | i += 1 |
|
54 | i += 1 | |
55 | else: |
|
55 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now