addset: implement first and last methods
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 06 Oct 2014 11:57:59 -0700
changeset 22810 7f97cb12782f
parent 22809 88dad916c008
child 22811 c1fd827e1ae0
addset: implement first and last methods The implementation is non-lazy for now. One may want to make it more lazy in the future.
mercurial/revset.py
--- 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