[PATCH 1 of 4] revset: added lazyset implementation to branch revset

Lucas Moscovicz lmoscovicz at fb.com
Tue Feb 11 12:50:50 CST 2014


# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1391645523 28800
#      Wed Feb 05 16:12:03 2014 -0800
# Node ID 44be4f156c4bc8f021bb303993d1311a0e4434c8
# Parent  3e472c6e812daadda941fadffd9ff404d0c1d175
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

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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()``


More information about the Mercurial-devel mailing list