ancestors: add a __nonzero__ method
This allows using the object in a conditional the same way we can use list.
--- a/mercurial/ancestor.py Fri Aug 15 15:25:12 2014 -0700
+++ b/mercurial/ancestor.py Fri Aug 15 15:57:50 2014 -0700
@@ -246,6 +246,14 @@
else:
self._containsseen = set()
+ def __nonzero__(self):
+ """False if the set is empty, True otherwise."""
+ try:
+ iter(self).next()
+ return True
+ except StopIteration:
+ return False
+
def __iter__(self):
"""Generate the ancestors of _initrevs in reverse topological order.