changeset 25648:9b9877d2b229

revset: rework 'filteredset.last' 'isascending' and 'isdescending' are methods, not attributes. This led 'last()' to misbehave on some non-ascending filtered sets.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 22 Jun 2015 13:48:01 -0700
parents 46a96dd4d976
children e90e031b3016
files mercurial/revset.py
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Mon Jun 22 10:19:12 2015 -0700
+++ b/mercurial/revset.py	Mon Jun 22 13:48:01 2015 -0700
@@ -3028,16 +3028,19 @@
 
     def last(self):
         it = None
-        if self._subset.isascending:
-            it = self.fastdesc
-        elif self._subset.isdescending:
+        if self.isascending():
             it = self.fastdesc
-        if it is None:
-            # slowly consume everything. This needs improvement
-            it = lambda: reversed(list(self))
-        for x in it():
+        elif self.isdescending():
+            it = self.fastasc
+        if it is not None:
+            for x in it():
+                return x
+            return None #empty case
+        else:
+            x = None
+            for x in self:
+                pass
             return x
-        return None
 
     def __repr__(self):
         return '<%s %r>' % (type(self).__name__, self._subset)