diff -r ec222a29bdf0 -r 94b200a11cf7 mercurial/util.py --- a/mercurial/util.py Tue Sep 13 17:01:07 2011 -0500 +++ b/mercurial/util.py Wed Sep 21 22:52:00 2011 +0200 @@ -24,6 +24,10 @@ def sha1(s): return _fastsha1(s) +_notset = object() +def safehasattr(thing, attr): + return getattr(thing, attr, _notset) is not _notset + def _fastsha1(s): # This function will import sha1 from hashlib or sha (whichever is # available) and overwrite itself with it on the first call.