Mercurial > hg
changeset 20710:9c1665f36588
merge with default
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 13 Mar 2014 15:00:34 -0500 |
parents | 71df845d86cf (diff) 2764148aa088 (current diff) |
children | b95490cf8abd |
files | mercurial/cmdutil.py |
diffstat | 2 files changed, 53 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Thu Mar 13 12:05:08 2014 -0500 +++ b/mercurial/cmdutil.py Thu Mar 13 15:00:34 2014 -0500 @@ -1296,7 +1296,7 @@ elif follow: revs = repo.revs('reverse(:.)') else: - revs = revset.baseset(repo) + revs = revset.spanset(repo) revs.reverse() if not revs: return []
--- a/mercurial/revset.py Thu Mar 13 12:05:08 2014 -0500 +++ b/mercurial/revset.py Thu Mar 13 15:00:34 2014 -0500 @@ -46,7 +46,7 @@ if parent != node.nullrev: heapq.heappush(h, -parent) - return descgeneratorset(iterate()) + return _descgeneratorset(iterate()) def _revdescendants(repo, revs, followfirst): """Like revlog.descendants() but supports followfirst.""" @@ -70,7 +70,7 @@ yield i break - return ascgeneratorset(iterate()) + return _ascgeneratorset(iterate()) def _revsbetween(repo, roots, heads): """Return all paths between roots and heads, inclusive of both endpoint @@ -540,19 +540,18 @@ return subset.filter(matches) def _children(repo, narrow, parentset): + cs = set() if not parentset: - return baseset([]) + return baseset(cs) pr = repo.changelog.parentrevs minrev = min(parentset) - - def matches(x): - if x <= minrev: - return False - for p in pr(x): + for r in narrow: + if r <= minrev: + continue + for p in pr(r): if p in parentset: - return True - - return narrow.filter(matches) + cs.add(r) + return baseset(cs) def children(repo, subset, x): """``children(set)`` @@ -2236,7 +2235,7 @@ return lazyset(self, lambda r: r not in x) def __add__(self, x): - return lazyset(addset(self, x)) + return lazyset(_addset(self, x)) def __nonzero__(self): for r in self: @@ -2307,9 +2306,14 @@ self._subset.reverse() self._ascending = not self._ascending -class addset(object): - """Wrapper structure for lazily adding two structures without losing much +class _addset(object): + """Represent the addition of two sets + + Wrapper structure for lazily adding two structures without losing much performance on the __contains__ method + + This class does not duck-type baseset and it's only supposed to be used + internally """ def __init__(self, revs1, revs2): self._r1 = revs1 @@ -2325,7 +2329,7 @@ for r in self._r2: if r not in s: yield r - self._iter = generatorset(gen()) + self._iter = _generatorset(gen()) return self._iter @@ -2336,11 +2340,16 @@ def __contains__(self, x): return x in self._r1 or x in self._r2 -class generatorset(object): - """Wrapper structure for generators that provides lazy membership and can +class _generatorset(object): + """Wrap a generator for lazy iteration + + Wrapper structure for generators that provides lazy membership and can be iterated more than once. When asked for membership it generates values until either it finds the requested one or has gone through all the elements in the generator + + This class does not duck-type baseset and it's only supposed to be used + internally """ def __init__(self, gen): self._gen = gen @@ -2348,6 +2357,7 @@ self._cache = {} self._genlist = baseset([]) self._iterated = False + self._finished = False def __contains__(self, x): if x in self._cache: @@ -2357,6 +2367,7 @@ if l == x: return True + self._finished = True self._cache[x] = False return False @@ -2372,12 +2383,26 @@ self._genlist.append(item) yield item + self._finished = True + def set(self): return self -class ascgeneratorset(generatorset): - """ Same structure as generatorset but stops iterating after it goes past + def sort(self, reverse=False): + # Basic implementation to be changed in future patches + if not self._finished: + for i in self: + continue + self._genlist.sort(reverse=reverse) + +class _ascgeneratorset(_generatorset): + """Wrap a generator of ascending elements for lazy iteration + + Same structure as _generatorset but stops iterating after it goes past the value when asked for membership and the element is not contained + + This class does not duck-type baseset and it's only supposed to be used + internally """ def __contains__(self, x): if x in self._cache: @@ -2392,9 +2417,14 @@ self._cache[x] = False return False -class descgeneratorset(generatorset): - """ Same structure as generatorset but stops iterating after it goes past +class _descgeneratorset(_generatorset): + """Wrap a generator of descending elements for lazy iteration + + Same structure as _generatorset but stops iterating after it goes past the value when asked for membership and the element is not contained + + This class does not duck-type baseset and it's only supposed to be used + internally """ def __contains__(self, x): if x in self._cache: @@ -2469,7 +2499,7 @@ return orderedlazyset(self, lambda r: r not in x, ascending=False) def __add__(self, x): - return lazyset(addset(self, x)) + return lazyset(_addset(self, x)) def __len__(self): if not self._hiddenrevs: