# HG changeset patch # User Brendan Cully # Date 1160598852 25200 # Node ID e44eadc92ec4fee4de92b1ab6ce2d1516ba3eaed # Parent 9061613c159381138fd2661f36fc5db09c4bc6a4 context: check self.__dict__ instead of using hasattr hasattr implicitly calls getattr, instantiating the field it is checking for. diff -r 9061613c1593 -r e44eadc92ec4 mercurial/context.py --- 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)