changeset 20461:abd8e56a1038

revset: added lazyset implementation to contains revset
author Lucas Moscovicz <lmoscovicz@fb.com>
date Tue, 04 Feb 2014 15:07:03 -0800
parents 3a88d0d0c6b6
children 0031ef5df586
files mercurial/revset.py
diffstat 1 files changed, 13 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Tue Feb 04 09:29:19 2014 -0800
+++ b/mercurial/revset.py	Tue Feb 04 15:07:03 2014 -0800
@@ -535,23 +535,21 @@
     """
     # i18n: "contains" is a keyword
     pat = getstring(x, _("contains requires a pattern"))
-    s = []
-    if not matchmod.patkind(pat):
-        pat = pathutil.canonpath(repo.root, repo.getcwd(), pat)
-        for r in subset:
-            if pat in repo[r]:
-                s.append(r)
-    else:
-        m = None
-        for r in subset:
-            c = repo[r]
-            if not m or matchmod.patkind(pat) == 'set':
-                m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
+
+    def matches(x):
+        if not matchmod.patkind(pat):
+            pats = pathutil.canonpath(repo.root, repo.getcwd(), pat)
+            if pats in repo[x]:
+                return True
+        else:
+            c = repo[x]
+            m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
             for f in c.manifest():
                 if m(f):
-                    s.append(r)
-                    break
-    return baseset(s)
+                    return True
+        return False
+
+    return lazyset(subset, matches)
 
 def converted(repo, subset, x):
     """``converted([id])``