revset: rework 'filteredset.last'
'isascending' and 'isdescending' are methods, not attributes. This led 'last()'
to misbehave on some non-ascending filtered sets.
--- 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)