mercurial/util.py
branchstable
changeset 12051 ff5cec76b1c5
parent 11758 a79214972da2
child 12054 5d22e631c365
child 12344 b6173aee4a47
equal deleted inserted replaced
12050:c5fd25c1bc4a 12051:ff5cec76b1c5
    26 
    26 
    27 def _fastsha1(s):
    27 def _fastsha1(s):
    28     # This function will import sha1 from hashlib or sha (whichever is
    28     # This function will import sha1 from hashlib or sha (whichever is
    29     # available) and overwrite itself with it on the first call.
    29     # available) and overwrite itself with it on the first call.
    30     # Subsequent calls will go directly to the imported function.
    30     # Subsequent calls will go directly to the imported function.
    31     try:
    31     if sys.version_info >= (2, 5):
    32         from hashlib import sha1 as _sha1
    32         from hashlib import sha1 as _sha1
    33     except ImportError:
    33     else:
    34         from sha import sha as _sha1
    34         from sha import sha as _sha1
    35     global _fastsha1, sha1
    35     global _fastsha1, sha1
    36     _fastsha1 = sha1 = _sha1
    36     _fastsha1 = sha1 = _sha1
    37     return _sha1(s)
    37     return _sha1(s)
    38 
    38