changeset 22810:7f97cb12782f

addset: implement first and last methods The implementation is non-lazy for now. One may want to make it more lazy in the future.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 06 Oct 2014 11:57:59 -0700
parents 88dad916c008
children c1fd827e1ae0
files mercurial/revset.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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