Mercurial > hg
diff mercurial/context.py @ 3336:e44eadc92ec4
context: check self.__dict__ instead of using hasattr
hasattr implicitly calls getattr, instantiating the field it is
checking for.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Wed, 11 Oct 2006 13:34:12 -0700 |
parents | 6c68bc1e7873 |
children | b02e60097bbe |
line wrap: on
line diff
--- a/mercurial/context.py Wed Oct 11 12:06:14 2006 -0700 +++ b/mercurial/context.py Wed Oct 11 13:34:12 2006 -0700 @@ -72,7 +72,7 @@ return [ changectx(self._repo, x) for x in c ] def filenode(self, path): - if hasattr(self, "_manifest"): + if '_manifest' in self.__dict__: try: return self._manifest[path] except KeyError: @@ -140,7 +140,7 @@ return self._changeid elif name == '_filenode': try: - if hasattr(self, "_fileid"): + if '_fileid' in self.__dict__: self._filenode = self._filelog.lookup(self._fileid) else: self._filenode = self._changectx.filenode(self._path) @@ -176,7 +176,7 @@ def filelog(self): return self._filelog def rev(self): - if hasattr(self, "_changectx"): + if '_changectx' in self.__dict__: return self._changectx.rev() return self._filelog.linkrev(self._filenode) @@ -439,7 +439,7 @@ filelog=self._filelog) def rev(self): - if hasattr(self, "_changectx"): + if '_changectx' in self.__dict__: return self._changectx.rev() return self._filelog.linkrev(self._filenode)