[PATCH 1 of 2] util: move md5 back next to sha1 and allow to call it without an argument

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Oct 12 03:28:22 CDT 2014



On 10/11/2014 01:38 AM, Mike Hommey wrote:
> # HG changeset patch
> # User Mike Hommey <mh at glandium.org>
> # Date 1411542047 -32400
> #      Wed Sep 24 16:00:47 2014 +0900
> # Node ID 225306662bbf7c8cc6d867d484eab1e038f6c2a5
> # Parent  a1eb21f5caea4366310e32aa85248791d5bbfa0c
> util: move md5 back next to sha1 and allow to call it without an argument
>
> This effectively backs out changeset 908c5906091b.

small nits, It would be useful to have more context about what motivate 
you to do such change.

>
> diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
> --- a/mercurial/keepalive.py
> +++ b/mercurial/keepalive.py
> @@ -14,18 +14,16 @@
>
>   # This file is part of urlgrabber, a high-level cross-protocol url-grabber
>   # Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
>
>   # Modified by Benoit Boissinot:
>   #  - fix for digest auth (inspired from urllib2.py @ Python v2.4)
>   # Modified by Dirkjan Ochtman:
>   #  - import md5 function from a local util module
> -# Modified by Martin Geisler:
> -#  - moved md5 function from local util module to this module
>   # Modified by Augie Fackler:
>   #  - add safesend method and use it to prevent broken pipe errors
>   #    on large POST requests
>
>   """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive.
>
>   >>> import urllib2
>   >>> from keepalive import HTTPHandler
> @@ -612,26 +610,18 @@ def error_handler(url):
>               raise
>           else:
>               print "  status = %s, reason = %s" % (status, reason)
>       HANDLE_ERRORS = orig
>       hosts = keepalive_handler.open_connections()
>       print "open connections:", hosts
>       keepalive_handler.close_all()
>
> -def md5(s):
> -    try:
> -        from hashlib import md5 as _md5
> -    except ImportError:
> -        from md5 import md5 as _md5
> -    global md5
> -    md5 = _md5
> -    return _md5(s)
> -
>   def continuity(url):
> +    from util import md5
>       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()
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -103,16 +103,25 @@ def _fastsha1(s=''):
>       if sys.version_info >= (2, 5):
>           from hashlib import sha1 as _sha1
>       else:
>           from sha import sha as _sha1
>       global _fastsha1, sha1
>       _fastsha1 = sha1 = _sha1
>       return _sha1(s)
>
> +def md5(s=''):
> +    try:
> +        from hashlib import md5 as _md5
> +    except ImportError:
> +        from md5 import md5 as _md5
> +    global md5
> +    md5 = _md5
> +    return _md5(s)
> +
>   try:
>       buffer = buffer
>   except NameError:
>       if sys.version_info[0] < 3:
>           def buffer(sliceable, offset=0):
>               return sliceable[offset:]
>       else:
>           def buffer(sliceable, offset=0):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list