Mercurial > evolve
changeset 4651:55c347b4874f
stack: implement __bool__ and __nonzero__
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 08 May 2019 15:57:54 +0800 |
parents | 7c05b1625921 |
children | b72cd597a887 |
files | hgext3rd/topic/stack.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)