[PATCH 2 of 3] bookmark: issue a single call to `allsuccessors` per loop

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Fri Nov 9 12:21:11 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1351094121 -7200
# Node ID 5c64f45fe1f3279d0a7c28c73f899b4b094d137b
# Parent  858ae42f38cf487dce799965216c1716f7bc3132
bookmark: issue a single call to `allsuccessors` per loop

Update to this code was minimalist when `allsuccessors` argument were changed
from a list to a set. As this code is getting my attention again I realised we
can drastically simplify this part of the code by issue a single call to
`allsuccessors`.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -261,15 +261,12 @@ def validdest(repo, old, new):
         plen = -1
         # compute the whole set of successors or descendants
         while len(validdests) != plen:
             plen = len(validdests)
             succs = set(c.node() for c in validdests)
-            for c in validdests:
-                if c.mutable():
-                    # obsolescence marker does not apply to public changeset
-                    succs.update(obsolete.allsuccessors(repo.obsstore,
-                                                        [c.node()]))
+            mutable = [c.node() for c in validdests if c.mutable()]
+            succs.update(obsolete.allsuccessors(repo.obsstore, mutable))
             known = (n for n in succs if n in nm)
             validdests = set(repo.set('%ln::', known))
         validdests.remove(old)
         return new in validdests
     else:


More information about the Mercurial-devel mailing list