revset: added operations to duck type baseset
authorLucas Moscovicz <lmoscovicz@fb.com>
Thu, 06 Feb 2014 14:29:37 -0800
changeset 20429 f5b560c60bcd
parent 20428 2e33cda452f6
child 20430 d98ba4a87427
revset: added operations to duck type baseset Added more operations which are not lazy but only used so far to duck type baseset. Their implementations will be changed in future patches.
mercurial/revset.py
--- a/mercurial/revset.py	Thu Feb 06 14:25:37 2014 -0800
+++ b/mercurial/revset.py	Thu Feb 06 14:29:37 2014 -0800
@@ -2100,5 +2100,26 @@
         l = baseset([r for r in self])
         return l + baseset(x)
 
+    def __len__(self):
+        # Basic implementation to be changed in future patches.
+        l = baseset([r for r in self])
+        return len(l)
+
+    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.
+        self._subset = baseset(self._subset)
+        self._subset.sort(reverse=reverse)
+
+    def reverse(self):
+        self._subset.reverse()
+
+    def set(self):
+        return set([r for r in self])
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()