[PATCH] keepalive: fix how md5 is used
Mike Hommey
mh at glandium.org
Wed Sep 24 01:56:37 CDT 2014
# HG changeset patch
# User Mike Hommey <mh at glandium.org>
# Date 1411541560 -32400
# Wed Sep 24 15:52:40 2014 +0900
# Node ID bc01442c6e030eee52c5f5524a28a50b1c25a4a6
# Parent 80ffdeecf26b373db4fd4a4bf26d548d456fa7b6
keepalive: fix how md5 is used
The code in keepalive dates from when it was importing the md5 module directly
and uses md5.new. Since then, what 'md5' means has been changed from an import
of the md5 module to being a function using the right module between hashlib
and md5, so the md5.new idiom doesn't work anymore.
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -630,38 +630,38 @@ def continuity(url):
format = '%25s: %s'
# first fetch the file with the normal http handler
opener = urllib2.build_opener()
urllib2.install_opener(opener)
fo = urllib2.urlopen(url)
foo = fo.read()
fo.close()
- m = md5.new(foo)
+ m = md5(foo)
print format % ('normal urllib', m.hexdigest())
# now install the keepalive handler and try again
opener = urllib2.build_opener(HTTPHandler())
urllib2.install_opener(opener)
fo = urllib2.urlopen(url)
foo = fo.read()
fo.close()
- m = md5.new(foo)
+ m = md5(foo)
print format % ('keepalive read', m.hexdigest())
fo = urllib2.urlopen(url)
foo = ''
while True:
f = fo.readline()
if f:
foo = foo + f
else: break
fo.close()
- m = md5.new(foo)
+ m = md5(foo)
print format % ('keepalive readline', m.hexdigest())
def comp(N, url):
print ' making %i connections to:\n %s' % (N, url)
sys.stdout.write(' first using the normal urllib handlers')
# first use normal opener
opener = urllib2.build_opener()
More information about the Mercurial-devel
mailing list