# HG changeset patch # User Sol Jerome # Date 2010-08-17 22:38:19 # Node ID ff5cec76b1c5b6be9c3bb923aae8c3c6d079d6b9 # Parent c5fd25c1bc4a69156caaff435bce81fb5e9aded2 util: avoid using hashlib on Python < 2.5 (issue2278) The following patch allows the use of python2.4 with a standalone hashlib rather than assuming that python2.5 is in use when hashlib is imported successfully. diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -28,9 +28,9 @@ def _fastsha1(s): # This function will import sha1 from hashlib or sha (whichever is # available) and overwrite itself with it on the first call. # Subsequent calls will go directly to the imported function. - try: + if sys.version_info >= (2, 5): from hashlib import sha1 as _sha1 - except ImportError: + else: from sha import sha as _sha1 global _fastsha1, sha1 _fastsha1 = sha1 = _sha1