From patchwork Mon Aug 12 16:27:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [07,of,41] basefilectx: move __nonzero__ from filectx From: Sean Farley X-Patchwork-Id: 2134 Message-Id: <2c149635c2c56835c152.1376324823@laptop.local> To: mercurial-devel@selenic.com Date: Mon, 12 Aug 2013 11:27:03 -0500 # HG changeset patch # User Sean Farley # Date 1376279113 18000 # Sun Aug 11 22:45:13 2013 -0500 # Node ID 2c149635c2c56835c152f02043608d803fcb9a63 # Parent b52d572a217745ae11073fb7f6f11ba0c0727abb basefilectx: move __nonzero__ from filectx diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -445,10 +445,18 @@ @propertycache def _repopath(self): return self._path + def __nonzero__(self): + try: + self._filenode + return True + except error.LookupError: + # file is missing + return False + class filectx(basefilectx): """A filecontext object makes access to data related to a particular filerevision convenient.""" def __init__(self, repo, path, changeid=None, fileid=None, filelog=None, changectx=None): @@ -494,18 +502,10 @@ # Linkrevs have several serious troubles with filtering that are # complicated to solve. Proper handling of the issue here should be # considered when solving linkrev issue are on the table. return changectx(self._repo.unfiltered(), self._changeid) - def __nonzero__(self): - try: - self._filenode - return True - except error.LookupError: - # file is missing - return False - def __str__(self): return "%s@%s" % (self.path(), short(self.node())) def __repr__(self): return "" % str(self)