comparison mercurial/keepalive.py @ 22505:232d437af120 stable

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.
author Mike Hommey <mh@glandium.org>
date Wed, 24 Sep 2014 15:52:40 +0900
parents 681f7b9213a4
children bb7a911b138e
comparison
equal deleted inserted replaced
22503:300e07582e9b 22505:232d437af120
633 opener = urllib2.build_opener() 633 opener = urllib2.build_opener()
634 urllib2.install_opener(opener) 634 urllib2.install_opener(opener)
635 fo = urllib2.urlopen(url) 635 fo = urllib2.urlopen(url)
636 foo = fo.read() 636 foo = fo.read()
637 fo.close() 637 fo.close()
638 m = md5.new(foo) 638 m = md5(foo)
639 print format % ('normal urllib', m.hexdigest()) 639 print format % ('normal urllib', m.hexdigest())
640 640
641 # now install the keepalive handler and try again 641 # now install the keepalive handler and try again
642 opener = urllib2.build_opener(HTTPHandler()) 642 opener = urllib2.build_opener(HTTPHandler())
643 urllib2.install_opener(opener) 643 urllib2.install_opener(opener)
644 644
645 fo = urllib2.urlopen(url) 645 fo = urllib2.urlopen(url)
646 foo = fo.read() 646 foo = fo.read()
647 fo.close() 647 fo.close()
648 m = md5.new(foo) 648 m = md5(foo)
649 print format % ('keepalive read', m.hexdigest()) 649 print format % ('keepalive read', m.hexdigest())
650 650
651 fo = urllib2.urlopen(url) 651 fo = urllib2.urlopen(url)
652 foo = '' 652 foo = ''
653 while True: 653 while True:
654 f = fo.readline() 654 f = fo.readline()
655 if f: 655 if f:
656 foo = foo + f 656 foo = foo + f
657 else: break 657 else: break
658 fo.close() 658 fo.close()
659 m = md5.new(foo) 659 m = md5(foo)
660 print format % ('keepalive readline', m.hexdigest()) 660 print format % ('keepalive readline', m.hexdigest())
661 661
662 def comp(N, url): 662 def comp(N, url):
663 print ' making %i connections to:\n %s' % (N, url) 663 print ' making %i connections to:\n %s' % (N, url)
664 664