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

Lucas Moscovicz lmoscovicz at fb.com
Tue Feb 11 14:55:21 CST 2014


# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at 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

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()``


More information about the Mercurial-devel mailing list