changeset 20729:caa69cb223b0

revset: added ascending and descending methods to _addset This methods are intended to duck-type baseset, so we will still have _addset as a private class but will be able return it without wrapping it into an orderedlazyset or a lazyset.
author Lucas Moscovicz <lmoscovicz@fb.com>
date Fri, 14 Mar 2014 10:21:56 -0700
parents 1c8b62c0a47e
children 180d47e1fb68
files mercurial/revset.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Thu Mar 13 19:12:36 2014 -0700
+++ b/mercurial/revset.py	Fri Mar 14 10:21:56 2014 -0700
@@ -2397,6 +2397,22 @@
             return orderedlazyset(self, condition, ascending=self._ascending)
         return lazyset(self, condition)
 
+    def ascending(self):
+        if self._ascending is None:
+            self.sort()
+            self._ascending = True
+        else:
+            if not self._ascending:
+                self.reverse()
+
+    def descending(self):
+        if self._ascending is None:
+            self.sort(reverse=True)
+            self._ascending = False
+        else:
+            if self._ascending:
+                self.reverse()
+
     def _iterator(self):
         """Iterate over both collections without repeating elements