revset: added lazyset implementation to matching revset
Performance Benchmarking:
$ time hg log -qr "first(matching(0))"
0:
9117c6561b0b
real 0m2.213s
user 0m2.149s
sys 0m0.055s
$ time ./hg log -qr "first(matching(0))"
0:
9117c6561b0b
real 0m0.177s
user 0m0.137s
sys 0m0.038s
--- a/mercurial/revset.py Tue Feb 04 08:51:07 2014 -0800
+++ b/mercurial/revset.py Tue Feb 04 09:14:45 2014 -0800
@@ -1365,18 +1365,18 @@
# is only one field to match)
getinfo = lambda r: [f(r) for f in getfieldfuncs]
- matches = set()
- for rev in revs:
- target = getinfo(rev)
- for r in subset:
+ def matches(x):
+ for rev in revs:
+ target = getinfo(rev)
match = True
for n, f in enumerate(getfieldfuncs):
- if target[n] != f(r):
+ if target[n] != f(x):
match = False
- break
if match:
- matches.add(r)
- return baseset([r for r in subset if r in matches])
+ return True
+ return False
+
+ return lazyset(subset, matches)
def reverse(repo, subset, x):
"""``reverse(set)``