[PATCH 5 of 6 V2] hidden: unify the static and dynamic blocker logic

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue May 23 16:02:33 EDT 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1495374426 -7200
#      Sun May 21 15:47:06 2017 +0200
# Node ID 66479a8be5d5adffd59d9b7a07f1d89a54ef66f4
# Parent  cb01cba8a41a4758c11ee235281a0946ccd5596a
# EXP-Topic fast-compute-hidden
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 66479a8be5d5
hidden: unify the static and dynamic blocker logic

We no longer have cache and they both work the same way. Unifying the logic
simplify the code and reduce the amount of set copies.

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -47,30 +47,6 @@ def revealedrevs(repo):
         blockers.update(rev(t[0]) for t in tags.values() if t[0] in nodemap)
     return blockers
 
-def _getstatichidden(repo):
-    """Revision to be hidden (disregarding dynamic blocker)
-
-    To keep a consistent graph, we cannot hide any revisions with
-    non-hidden descendants. This function computes the set of
-    revisions that could be hidden while keeping the graph consistent.
-
-    A second pass will be done to apply "dynamic blocker" like bookmarks or
-    working directory parents.
-
-    """
-    assert not repo.changelog.filteredrevs
-    hidden = hideablerevs(repo)
-    if hidden:
-        pfunc = repo.changelog.parentrevs
-
-        mutablephases = (phases.draft, phases.secret)
-        mutable = repo._phasecache.getrevset(repo, mutablephases)
-        blockers = _consistencyblocker(pfunc, hidden, mutable)
-
-        if blockers:
-            hidden = hidden - _domainancestors(pfunc, blockers, mutable)
-    return hidden
-
 def _consistencyblocker(pfunc, hideable, domain):
     """return non-hideable changeset blocking hideable one
 
@@ -117,21 +93,20 @@ def computehidden(repo):
     During most operation hidden should be filtered."""
     assert not repo.changelog.filteredrevs
 
-    hidden = frozenset()
-    hideable = hideablerevs(repo)
-    if hideable:
-        cl = repo.changelog
-        hidden = frozenset(_getstatichidden(repo))
+    hidden = hideablerevs(repo)
+    if hidden:
+        pfunc = repo.changelog.parentrevs
+        mutablephases = (phases.draft, phases.secret)
+        mutable = repo._phasecache.getrevset(repo, mutablephases)
+
+        blockers = _consistencyblocker(pfunc, hidden, mutable)
 
         # check if we have wd parents, bookmarks or tags pointing to hidden
         # changesets and remove those.
-        dynamic = hidden & revealedrevs(repo)
-        if dynamic:
-            pfunc = cl.parentrevs
-            mutablephases = (phases.draft, phases.secret)
-            mutable = repo._phasecache.getrevset(repo, mutablephases)
-            hidden = hidden - _domainancestors(pfunc, dynamic, mutable)
-    return hidden
+        blockers |= (hidden & revealedrevs(repo))
+        if blockers:
+            hidden = hidden - _domainancestors(pfunc, blockers, mutable)
+    return frozenset(hidden)
 
 def computeunserved(repo):
     """compute the set of revision that should be filtered when used a server


More information about the Mercurial-devel mailing list