generatorset: implement __len__
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 15 Oct 2014 04:28:55 -0700
changeset 22996 a43d929d1fa1
parent 22995 2587631c5f8a
child 22997 d16804069db1
generatorset: implement __len__ It was the only smartset class without a `__len__` implementation.
mercurial/revset.py
--- a/mercurial/revset.py	Wed Oct 15 04:26:23 2014 -0700
+++ b/mercurial/revset.py	Wed Oct 15 04:28:55 2014 -0700
@@ -2776,6 +2776,11 @@
             self.fastasc = asc.__iter__
             self.fastdesc = asc.__reversed__
 
+    def __len__(self):
+        for x in self._consumegen():
+            pass
+        return len(self._genlist)
+
     def sort(self, reverse=False):
         self._ascending = not reverse