util: move md5 back next to sha1 and allow to call it without an argument
authorMike Hommey <mh@glandium.org>
Wed, 24 Sep 2014 16:00:47 +0900
changeset 22958 bb7a911b138e
parent 22957 11855ba3904c
child 22959 10116463b0b1
util: move md5 back next to sha1 and allow to call it without an argument This effectively backs out changeset 908c5906091b. The API change is done so that both util.sha1 and util.md5 can be called the same way. The function is moved in order to use it for md5 checksumming for an upcoming bundle2 feature.
mercurial/keepalive.py
mercurial/util.py
--- a/mercurial/keepalive.py	Thu Oct 16 03:22:51 2014 -0700
+++ b/mercurial/keepalive.py	Wed Sep 24 16:00:47 2014 +0900
@@ -19,8 +19,6 @@
 #  - 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
@@ -617,16 +615,8 @@
     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	Thu Oct 16 03:22:51 2014 -0700
+++ b/mercurial/util.py	Wed Sep 24 16:00:47 2014 +0900
@@ -108,6 +108,15 @@
     _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: