# HG changeset patch # User Lucas Moscovicz # Date 1392310825 28800 # Node ID 2d52f37937b0f83077a4ffa8f381132329924c10 # Parent f3c8db3d6d66550b050e02b592c84e3705b9f899 revset: changed lazyset __add__ implementation to work lazily Performance Benchmarking: $ time hg log -qr "first(author(mpm) or branch(default))" 0:9117c6561b0b real 0m3.875s user 0m3.818s sys 0m0.051s $ time ./hg log -qr "first(author(mpm) or branch(default))" 0:9117c6561b0b real 0m0.213s user 0m0.174s sys 0m0.038s diff -r f3c8db3d6d66 -r 2d52f37937b0 mercurial/revset.py --- a/mercurial/revset.py Tue Feb 25 10:32:54 2014 -0800 +++ b/mercurial/revset.py Thu Feb 13 09:00:25 2014 -0800 @@ -2151,7 +2151,7 @@ the subset and contains a function which tests for membership in the revset """ - def __init__(self, subset, condition): + def __init__(self, subset, condition=lambda x: True): self._subset = subset self._condition = condition self._cache = {} @@ -2175,8 +2175,14 @@ return lazyset(self, lambda r: r not in x) def __add__(self, x): - l = baseset([r for r in self]) - return l + baseset(x) + def iterates(): + for r in self: + yield r + for r in x: + if r not in self: + yield r + + return lazyset(generatorset(iterates())) def __nonzero__(self): for r in self: