[PATCH 5 of 8] revset: added lazyset implementation to matching revset
Lucas Moscovicz
lmoscovicz at fb.com
Tue Feb 11 21:54:43 UTC 2014
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1391534085 28800
# Tue Feb 04 09:14:45 2014 -0800
# Node ID a8a52182a974dbc41acb911ffd8feb7b1c77077b
# Parent 7a047e944f639aa3663f40e4f922ec9df9eb0c82
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
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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)``
More information about the Mercurial-devel
mailing list