comparison mercurial/util.py @ 15392:d7bfbc92a1c0 stable

util: add a doctest for empty sha() calls
author Matt Mackall <mpm@selenic.com>
date Mon, 31 Oct 2011 15:41:39 -0500
parents fffe49886a51
children de7e2fba4326 6eff984d8e76
comparison
equal deleted inserted replaced
15391:a5a6a9b7f3b9 15392:d7bfbc92a1c0
72 username = platform.username 72 username = platform.username
73 73
74 # Python compatibility 74 # Python compatibility
75 75
76 def sha1(s=''): 76 def sha1(s=''):
77 '''
78 Low-overhead wrapper around Python's SHA support
79
80 >>> f = _fastsha1
81 >>> a = sha1()
82 >>> a = f()
83 >>> a.hexdigest()
84 'da39a3ee5e6b4b0d3255bfef95601890afd80709'
85 '''
86
77 return _fastsha1(s) 87 return _fastsha1(s)
78 88
79 _notset = object() 89 _notset = object()
80 def safehasattr(thing, attr): 90 def safehasattr(thing, attr):
81 return getattr(thing, attr, _notset) is not _notset 91 return getattr(thing, attr, _notset) is not _notset