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

login
register
mail settings
Submitter Pierre-Yves David
Date May 23, 2017, 8:02 p.m.
Message ID <66479a8be5d5adffd59d.1495569753@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20870/
State Changes Requested
Headers show

Comments

Pierre-Yves David - May 23, 2017, 8:02 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.

Patch

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