changeset 22827:c1107cb21df2

baseset: prepare lazy ordering in __iter__ We'll explicitly track the order of the baseset to take advantage of the ascending and descending lists during iteration.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 03 Oct 2014 03:26:18 -0500
parents 4ffb327e4719
children 966860f7a1a8
files mercurial/revset.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Fri Oct 03 03:19:23 2014 -0500
+++ b/mercurial/revset.py	Fri Oct 03 03:26:18 2014 -0500
@@ -2331,6 +2331,7 @@
             data = list(data)
         self._list = data
         self._set = None
+        self._ascending = None
 
     @util.propertycache
     def _asclist(self):
@@ -2338,6 +2339,14 @@
         asclist.sort()
         return asclist
 
+    def __iter__(self):
+        if self._ascending is None:
+            return iter(self._list)
+        elif self._ascending:
+            return iter(self._asclist)
+        else:
+            return reversed(self._asclist)
+
     def fastasc(self):
         return iter(self._asclist)
 
@@ -2368,9 +2377,6 @@
     def reverse(self):
         self._list.reverse()
 
-    def __iter__(self):
-        return iter(self._list)
-
     def __len__(self):
         return len(self._list)