Mercurial > public > mercurial-scm > hg-stable
diff mercurial/smartset.py @ 33121:247bae545061
smartset: fix generatorset.last() to not return the first element (issue5609)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 27 Jun 2017 23:50:22 +0900 |
parents | 6d767d62b25e |
children | 01c9700fbf9f |
line wrap: on
line diff
--- a/mercurial/smartset.py Mon Jun 26 21:11:02 2017 -0700 +++ b/mercurial/smartset.py Tue Jun 27 23:50:22 2017 +0900 @@ -766,6 +766,11 @@ be iterated more than once. When asked for membership it generates values until either it finds the requested one or has gone through all the elements in the generator + + >>> xs = generatorset([0, 1, 4], iterasc=True) + >>> assert xs.last() == xs.last() + >>> xs.last() # cached + 4 """ def __init__(self, gen, iterasc=None): """ @@ -937,7 +942,7 @@ # we need to consume all and try again for x in self._consumegen(): pass - return self.first() + return self.last() return next(it(), None) def __repr__(self):