comparison mercurial/ancestor.py @ 22225:baecf4e1b7d0

ancestors: add a __nonzero__ method This allows using the object in a conditional the same way we can use list.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 15 Aug 2014 15:57:50 -0700
parents 64911a12dc28
children 3a7d9c0c57a5
comparison
equal deleted inserted replaced
22224:f713de1d3916 22225:baecf4e1b7d0
244 if inclusive: 244 if inclusive:
245 self._containsseen = set(revs) 245 self._containsseen = set(revs)
246 else: 246 else:
247 self._containsseen = set() 247 self._containsseen = set()
248 248
249 def __nonzero__(self):
250 """False if the set is empty, True otherwise."""
251 try:
252 iter(self).next()
253 return True
254 except StopIteration:
255 return False
256
249 def __iter__(self): 257 def __iter__(self):
250 """Generate the ancestors of _initrevs in reverse topological order. 258 """Generate the ancestors of _initrevs in reverse topological order.
251 259
252 If inclusive is False, yield a sequence of revision numbers starting 260 If inclusive is False, yield a sequence of revision numbers starting
253 with the parents of each revision in revs, i.e., each revision is *not* 261 with the parents of each revision in revs, i.e., each revision is *not*