abstractsmartset: add a default implementation for min and max
This default implementation takes advantage of the fast iterator if available.
--- a/mercurial/revset.py Thu Oct 02 18:52:09 2014 -0500
+++ b/mercurial/revset.py Thu Oct 02 18:59:41 2014 -0500
@@ -2248,11 +2248,19 @@
def min(self):
"""return the minimum element in the set"""
- raise NotImplementedError()
+ if self.fastasc is not None:
+ for r in self.fastasc():
+ return r
+ raise ValueError('arg is an empty sequence')
+ return min(self)
def max(self):
"""return the maximum element in the set"""
- raise NotImplementedError()
+ if self.fastdesc is not None:
+ for r in self.fastdesc():
+ return r
+ raise ValueError('arg is an empty sequence')
+ return max(self)
def reverse(self):
"""reverse the expected iteration order"""