changeset 20484:0f1ef9e9e904

revset: added operations to spanset to duck type baseset Added more operations which are not lazy but only used so far to duck type baseset.
author Lucas Moscovicz <lmoscovicz@fb.com>
date Thu, 06 Feb 2014 15:56:25 -0800
parents ed57358398af
children de2544933139
files mercurial/revset.py
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Wed Feb 12 10:22:43 2014 -0800
+++ b/mercurial/revset.py	Thu Feb 06 15:56:25 2014 -0800
@@ -2159,5 +2159,27 @@
         l = baseset(self)
         return l + baseset(x)
 
+    def __len__(self):
+        return abs(self._end - self._start)
+
+    def __getitem__(self, x):
+        # Basic implementation to be changed in future patches.
+        l = baseset([r for r in self])
+        return l[x]
+
+    def sort(self, reverse=False):
+        # Basic implementation to be changed in future patches.
+        if reverse:
+            self.reverse()
+
+    def reverse(self):
+        if self._start <= self._end:
+            self._start, self._end = self._end - 1, self._start - 1
+        else:
+            self._start, self._end = self._end + 1, self._start + 1
+
+    def set(self):
+        return self
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()