[PATCH] revset: use parentsets.min in _children

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jun 12 20:38:16 CDT 2015

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1434074544 25200
#      Thu Jun 11 19:02:24 2015 -0700
# Node ID 708933d38cfe3a0df239e1ec0a6dfff5f7424cc4
# Parent  4388714b846e21cb2fefb686220c7c0d2df1b85a
revset: use parentsets.min in _children

As stated in the comment, using the smartset 'min' will give more opportunity to
be smart. It give a small but significant boost to the performance. Most of the
time is still spend doing the actual computation but at least we can scrap some
performance when it makes sense.

revset #0: roots(0:tip)
0) 0.046600
1) 0.044109  94%

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -616,13 +616,11 @@ def checkstatus(repo, subset, pat, field
 def _children(repo, narrow, parentset):
     if not parentset:
         return baseset()
     cs = set()
     pr = repo.changelog.parentrevs
-    # XXX this should be 'parentset.min()' assuming 'parentset' is a smartset
-    # (and if it is not, it should.)
-    minrev = min(parentset)
+    minrev = parentset.min()
     for r in narrow:
         if r <= minrev:
         for p in pr(r):
             if p in parentset:

More information about the Mercurial-devel mailing list