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

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 11, 2014, 6:50 p.m.
Message ID <9e46d74473bc91834157.1392144652@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3572/
State Accepted
Commit abb91b74f75872f0345b5b333a975d2bc7e92612
Headers show

Comments

Lucas Moscovicz - Feb. 11, 2014, 6:50 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@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

Patch

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])``