Mercurial > evolve
comparison hgext3rd/topic/stack.py @ 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 |
comparison
equal
deleted
inserted
replaced
4650:7c05b1625921 | 4651:55c347b4874f |
---|---|
74 def __iter__(self): | 74 def __iter__(self): |
75 return iter(self.revs) | 75 return iter(self.revs) |
76 | 76 |
77 def __getitem__(self, index): | 77 def __getitem__(self, index): |
78 return self.revs[index] | 78 return self.revs[index] |
79 | |
80 def __nonzero__(self): | |
81 return bool(self._revs) | |
82 | |
83 __bool__ = __nonzero__ | |
79 | 84 |
80 def index(self, item): | 85 def index(self, item): |
81 return self.revs.index(item) | 86 return self.revs.index(item) |
82 | 87 |
83 @util.propertycache | 88 @util.propertycache |