mercurial/util.py
changeset 8281 3e1e499db9d7
parent 8280 0b02d98d44d0
child 8295 1ea7e7d90007
--- a/mercurial/util.py	Sat May 02 23:05:35 2009 +0200
+++ b/mercurial/util.py	Sun May 03 00:03:35 2009 +0200
@@ -20,28 +20,26 @@
 
 # Python compatibility
 
-_md5 = None
 def md5(s):
-    global _md5
-    if _md5 is None:
-        try:
-            import hashlib
-            _md5 = hashlib.md5
-        except ImportError:
-            import md5
-            _md5 = md5.md5
+    try:
+        import hashlib
+        _md5 = hashlib.md5
+    except ImportError:
+        import md5
+        _md5 = md5.md5
+    global md5
+    md5 = _md5
     return _md5(s)
 
-_sha1 = None
 def sha1(s):
-    global _sha1
-    if _sha1 is None:
-        try:
-            import hashlib
-            _sha1 = hashlib.sha1
-        except ImportError:
-            import sha
-            _sha1 = sha.sha
+    try:
+        import hashlib
+        _sha1 = hashlib.sha1
+    except ImportError:
+        import sha
+        _sha1 = sha.sha
+    global sha1
+    sha1 = _sha1
     return _sha1(s)
 
 import subprocess