# HG changeset patch # User Pierre-Yves David # Date 1412324778 18000 # Node ID c1107cb21df2116f29fe9162ce8c49c4c8527cb7 # Parent 4ffb327e471981c4370087857768557e293c8264 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. diff -r 4ffb327e4719 -r c1107cb21df2 mercurial/revset.py --- 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)