Mercurial > hg-stable
changeset 8296:908c5906091b
util: remove md5
This hash function is broken and should not be used by new code. It is
currently only used by keepalive.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Mon, 04 May 2009 21:30:39 +0200 |
parents | 1ea7e7d90007 |
children | 7f27e69dd27f |
files | mercurial/keepalive.py mercurial/util.py tests/test-archive |
diffstat | 3 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/keepalive.py Mon May 04 20:29:05 2009 +0200 +++ b/mercurial/keepalive.py Mon May 04 21:30:39 2009 +0200 @@ -21,6 +21,8 @@ # - 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 """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive. @@ -528,8 +530,16 @@ 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
--- a/mercurial/util.py Mon May 04 20:29:05 2009 +0200 +++ b/mercurial/util.py Mon May 04 21:30:39 2009 +0200 @@ -20,16 +20,6 @@ # Python compatibility -def md5(s): - try: - import hashlib - _md5 = hashlib.md5 - except ImportError: - from md5 import md5 as _md5 - global md5 - md5 = _md5 - return _md5(s) - def sha1(s): try: import hashlib
--- a/tests/test-archive Mon May 04 20:29:05 2009 +0200 +++ b/tests/test-archive Mon May 04 21:30:39 2009 +0200 @@ -75,7 +75,10 @@ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" cat > md5comp.py <<EOF -from mercurial.util import md5 +try: + from hashlib import md5 +except ImportError: + from md5 import md5 import sys f1, f2 = sys.argv[1:3] h1 = md5(file(f1, 'rb').read()).hexdigest()