changeset 20459:51890507c6b3

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
author Lucas Moscovicz <lmoscovicz@fb.com>
date Tue, 04 Feb 2014 09:14:45 -0800
parents 8dabcc889e33
children 3a88d0d0c6b6
files mercurial/revset.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Tue Feb 04 08:51:07 2014 -0800
+++ b/mercurial/revset.py	Tue Feb 04 09:14:45 2014 -0800
@@ -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)``