addset: implement first and last methods
The implementation is non-lazy for now. One may want to make it more lazy in the
future.
--- a/mercurial/revset.py Mon Oct 06 11:54:53 2014 -0700
+++ b/mercurial/revset.py Mon Oct 06 11:57:59 2014 -0700
@@ -2618,6 +2618,16 @@
if self._ascending is not None:
self._ascending = not self._ascending
+ def first(self):
+ if self:
+ return self._list.first()
+ return None
+
+ def last(self):
+ if self:
+ return self._list.last()
+ return None
+
class generatorset(abstractsmartset):
"""Wrap a generator for lazy iteration