stack: implement __bool__ and __nonzero__
authorAnton Shestakov <av6@dwimlabs.net>
Wed, 08 May 2019 15:57:54 +0800
changeset 4651 55c347b4874f
parent 4650 7c05b1625921
child 4652 b72cd597a887
stack: implement __bool__ and __nonzero__
hgext3rd/topic/stack.py
--- a/hgext3rd/topic/stack.py	Sun May 05 17:39:46 2019 +0800
+++ b/hgext3rd/topic/stack.py	Wed May 08 15:57:54 2019 +0800
@@ -77,6 +77,11 @@
     def __getitem__(self, index):
         return self.revs[index]
 
+    def __nonzero__(self):
+        return bool(self._revs)
+
+    __bool__ = __nonzero__
+
     def index(self, item):
         return self.revs.index(item)