mercurial/util.py
branchstable
changeset 15152 94b200a11cf7
parent 15074 64fbd0de9773
child 15157 c208dcd0f709
equal deleted inserted replaced
15095:ec222a29bdf0 15152:94b200a11cf7
    21 
    21 
    22 # Python compatibility
    22 # Python compatibility
    23 
    23 
    24 def sha1(s):
    24 def sha1(s):
    25     return _fastsha1(s)
    25     return _fastsha1(s)
       
    26 
       
    27 _notset = object()
       
    28 def safehasattr(thing, attr):
       
    29     return getattr(thing, attr, _notset) is not _notset
    26 
    30 
    27 def _fastsha1(s):
    31 def _fastsha1(s):
    28     # This function will import sha1 from hashlib or sha (whichever is
    32     # This function will import sha1 from hashlib or sha (whichever is
    29     # available) and overwrite itself with it on the first call.
    33     # available) and overwrite itself with it on the first call.
    30     # Subsequent calls will go directly to the imported function.
    34     # Subsequent calls will go directly to the imported function.