[PATCH 4 of 4] revset: added lazyset implementation to keyword revset
Lucas Moscovicz
lmoscovicz at fb.com
Thu Feb 6 12:02:42 CST 2014
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1391015043 28800
# Wed Jan 29 09:04:03 2014 -0800
# Node ID 5c3c6f8aad6966b3c33de51e533e39bfd8179f02
# Parent da06f86f6560bcd74ea6740c3858a6a482a5e281
revset: added lazyset implementation to keyword revset
Performance benchmarking:
$ time hg log -l1 -qr "keyword(changeset)"
0:9117c6561b0b
real 0m3.466s
user 0m3.345s
sys 0m0.072s
$ time ./hg log -l1 -qr "keyword(changeset)"
0:9117c6561b0b
real 0m0.365s
user 0m0.199s
sys 0m0.083s
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -937,13 +937,13 @@
"""
# i18n: "keyword" is a keyword
kw = encoding.lower(getstring(x, _("keyword requires a string")))
- l = []
- for r in subset:
+
+ def matches(r):
c = repo[r]
- if util.any(kw in encoding.lower(t)
- for t in c.files() + [c.user(), c.description()]):
- l.append(r)
- return baseset(l)
+ return util.any(kw in encoding.lower(t) for t in c.files() + [c.user(),
+ c.description()])
+
+ return lazyset(subset, matches)
def limit(repo, subset, x):
"""``limit(set, [n])``
More information about the Mercurial-devel
mailing list