changeset 3168:05c588e1803d

context: add __nonzero__ methods
author Matt Mackall <mpm@selenic.com>
date Fri, 29 Sep 2006 17:47:51 -0500
parents e67c22bc8bba
children 9e002614f2eb
files mercurial/context.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Fri Sep 29 16:39:38 2006 -0500
+++ b/mercurial/context.py	Fri Sep 29 17:47:51 2006 -0500
@@ -37,6 +37,9 @@
     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 @@
         else:
             raise AttributeError, name
 
+    def __nonzero__(self):
+        return self._filerev != nullid
+
     def __str__(self):
         return "%s@%s" % (self.path(), short(self.node()))