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

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 6, 2014, 6:02 p.m.
Message ID <5c3c6f8aad6966b3c33d.1391709762@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3496/
State Superseded
Commit abb91b74f75872f0345b5b333a975d2bc7e92612
Headers show

Comments

Lucas Moscovicz - Feb. 6, 2014, 6:02 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@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
Matt Mackall - Feb. 6, 2014, 8:01 p.m.
On Thu, 2014-02-06 at 10:02 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@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

The remainder of these look like they'll be fine once you address the
concerns for patch 1.

Patch

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