[PATCH] keepalive: fix how md5 is used

Augie Fackler raf at durin42.com
Wed Sep 24 09:05:25 CDT 2014


On Wed, Sep 24, 2014 at 03:56:37PM +0900, Mike Hommey wrote:
> # 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

Queued for stable, though you're probably right that this is dead code.

>
> 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()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list