changeset 20458:8dabcc889e33

revset: added lazyset implementation to _matchfiles Performance Benchmarking: $ time hg log -qr "first(file(README))" 0:9117c6561b0b real 0m2.234s user 0m2.180s sys 0m0.044s $ time ./hg log -qr "first(file(README))" 0:9117c6561b0b real 0m0.172s user 0m0.129s sys 0m0.042s
author Lucas Moscovicz <lmoscovicz@fb.com>
date Tue, 04 Feb 2014 08:51:07 -0800
parents ed7b674824a3
children 51890507c6b3
files mercurial/revset.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Fri Jan 31 10:47:51 2014 -0800
+++ b/mercurial/revset.py	Tue Feb 04 08:51:07 2014 -0800
@@ -857,10 +857,10 @@
             hasset = True
     if not default:
         default = 'glob'
-    m = None
-    s = []
-    for r in subset:
-        c = repo[r]
+
+    def matches(x):
+        m = None
+        c = repo[x]
         if not m or (hasset and rev is None):
             ctx = c
             if rev is not None:
@@ -869,9 +869,10 @@
                                exclude=exc, ctx=ctx, default=default)
         for f in c.files():
             if m(f):
-                s.append(r)
-                break
-    return baseset(s)
+                return True
+        return False
+
+    return lazyset(subset, matches)
 
 def hasfile(repo, subset, x):
     """``file(pattern)``