# HG changeset patch # User Matt Mackall # Date 1159570071 18000 # Node ID 05c588e1803dc96b29913f81a0878414eb274f0c # Parent e67c22bc8bba14d5bf57abed4b48be81502a36fe context: add __nonzero__ methods diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -37,6 +37,9 @@ class changectx(object): def __eq__(self, other): return self._rev == other._rev + def __nonzero__(self): + return self._rev != -1 + def changeset(self): try: return self._changeset @@ -129,6 +132,9 @@ class filectx(object): else: raise AttributeError, name + def __nonzero__(self): + return self._filerev != nullid + def __str__(self): return "%s@%s" % (self.path(), short(self.node()))