Patchwork [1,of,8] revset: added lazyset implementation to public revset

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 11, 2014, 9:54 p.m.
Message ID <9851a5014e418df1a1c9.1392155679@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3590/
State Accepted
Commit 9a49feb408f3863cc0f537c2afe2e2005467aafb
Headers show

Comments

Lucas Moscovicz - Feb. 11, 2014, 9:54 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1391132768 28800
#      Thu Jan 30 17:46:08 2014 -0800
# Node ID 9851a5014e418df1a1c908d1755d65836559c0c8
# Parent  51bd527874fd789bf3b7ef45285a14d375626100
revset: added lazyset implementation to public revset

Performance Benchmarking:

$ time hg log -qr "first(public())"
...

real  0m1.184s
user  0m1.051s
sys 0m0.130s

$ time ./hg log -qr "first(public())"
...

real  0m0.548s
user  0m0.427s
sys 0m0.118s

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1202,7 +1202,7 @@ 
     # i18n: "public" is a keyword
     getargs(x, 0, 0, _("public takes no arguments"))
     pc = repo._phasecache
-    return baseset([r for r in subset if pc.phase(repo, r) == phases.public])
+    return lazyset(subset, lambda r: pc.phase(repo, r) == phases.public)
 
 def remote(repo, subset, x):
     """``remote([id [,path]])``