hidden: unify the static and dynamic blocker logic
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 21 May 2017 15:47:06 +0200
changeset 37692 4c5bc7cbd98943c47a38c157060fa6683ed6542a
parent 37691 1cc7c96cad75731c73ca859ae4893e400e6db904
child 37693 43ae9e6eaabaeeb8c070dd04a6280180745b5256
push id525
push usergszorc@mozilla.com
push dateFri, 09 Jun 2017 06:37:32 +0000
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.
mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -42,40 +42,16 @@ def revealedrevs(repo):
 
     tags = {}
     tagsmod.readlocaltags(repo.ui, repo, tags, {})
     if tags:
         rev, nodemap = cl.rev, cl.nodemap
         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
 
     For consistency, we cannot actually hide a changeset if one of it children
     are visible, this function find such children.
     """
     others = domain - hideable
     blockers = set()
@@ -124,31 +100,30 @@ def _domainancestors(pfunc, revs, domain
     return ancestors
 
 def computehidden(repo):
     """compute the set of hidden revision to filter
 
     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
 
     Secret and hidden changeset should not pretend to be here."""
     assert not repo.changelog.filteredrevs
     # fast path in simple case to avoid impact of non optimised code
     hiddens = filterrevs(repo, 'visible')