# HG changeset patch # User Matt Mackall # Date 2011-10-31 19:22:11 # Node ID fffe49886a51d664f798aca561130e16d73a76f7 # Parent 3bece03bf3c60a76138b745d550205fc984d25a9 util: allow sha1() with no args Normally this works because we replace util.sha1 with hashlib.sha1 after first use, but if the first user doesn't provide an arg, it breaks. diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -73,14 +73,14 @@ username = platform.username # Python compatibility -def sha1(s): +def sha1(s=''): return _fastsha1(s) _notset = object() def safehasattr(thing, attr): return getattr(thing, attr, _notset) is not _notset -def _fastsha1(s): +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.