Mercurial > hg
changeset 22722:e8832cf1abf6
abstractsmartset: add a default implementation for min and max
This default implementation takes advantage of the fast iterator if available.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 02 Oct 2014 18:59:41 -0500 |
parents | adc43967d401 |
children | d4706faa2061 |
files | mercurial/revset.py |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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"""