revset: added lazyset implementation to branch revset
authorLucas Moscovicz <lmoscovicz@fb.com>
Wed, 05 Feb 2014 16:12:03 -0800
changeset 20445 507261c0914f
parent 20444 1478a9ce6790
child 20446 d258486604f4
revset: added lazyset implementation to branch revset Performance Benchmarking: $ time hg log -l1 -qr "branch(default)" 0:9117c6561b0b real 0m3.366s user 0m3.217s sys 0m0.095s $ time ./hg log -l1 -qr "branch(default)" 0:9117c6561b0b real 0m0.389s user 0m0.199s sys 0m0.061s
mercurial/revset.py
--- a/mercurial/revset.py	Tue Feb 11 01:15:07 2014 +0100
+++ b/mercurial/revset.py	Wed Feb 05 16:12:03 2014 -0800
@@ -430,16 +430,16 @@
             # note: falls through to the revspec case if no branch with
             # this name exists
             if pattern in repo.branchmap():
-                return baseset([r for r in subset if matcher(repo[r].branch())])
+                return lazyset(subset, lambda r: matcher(repo[r].branch()))
         else:
-            return baseset([r for r in subset if matcher(repo[r].branch())])
+            return lazyset(subset, lambda r: matcher(repo[r].branch()))
 
     s = getset(repo, baseset(repo), x)
     b = set()
     for r in s:
         b.add(repo[r].branch())
     s = s.set()
-    return baseset([r for r in subset if r in s or repo[r].branch() in b])
+    return lazyset(subset, lambda r: r in s or repo[r].branch() in b)
 
 def bumped(repo, subset, x):
     """``bumped()``