Patchwork [6,of,8] revset: added lazyset implementation to merge revset

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 11, 2014, 8:55 p.m.
Message ID <bd6b1d895339c2dfe980.1392152121@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3577/
State Accepted
Commit 47fd57f650e5d91ce85b379c292e5c2b280c1a46
Headers show

Comments

Lucas Moscovicz - Feb. 11, 2014, 8:55 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1391129249 28800
#      Thu Jan 30 16:47:29 2014 -0800
# Node ID bd6b1d895339c2dfe98051653bc17fc23a0bb8c3
# Parent  e83543ce7069828b0271f798b68fd682f8174c03
revset: added lazyset implementation to merge revset

Performance benchmarking:

$ time hg log -qr "first(merge())"
102:58039eddbdda

real  0m0.276s
user  0m0.208s
sys 0m0.047s

$ time ./hg log -qr "first(merge())"
102:58039eddbdda

real  0m0.192s
user  0m0.154s
sys 0m0.027s

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -992,7 +992,7 @@ 
     # i18n: "merge" is a keyword
     getargs(x, 0, 0, _("merge takes no arguments"))
     cl = repo.changelog
-    return baseset([r for r in subset if cl.parentrevs(r)[1] != -1])
+    return lazyset(subset, lambda r: cl.parentrevs(r)[1] != -1)
 
 def branchpoint(repo, subset, x):
     """``branchpoint()``