[PATCH 3 of 4] revset: added lazyset implementation to keyword revset

Lucas Moscovicz lmoscovicz at fb.com
Tue Feb 11 12:50:52 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 9e46d74473bc918341572a5b94737a20b56e01b1
# Parent  6a54b66aa4d1acaa02bb1292d4432cc37bdd6266
revset: added lazyset implementation to keyword revset

Performance benchmarking:

$ time hg log -qr "first(keyword(changeset))"
0:9117c6561b0b

real  0m3.466s
user  0m3.345s
sys 0m0.072s

$ time ./hg log -qr "first(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
@@ -921,13 +921,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