Patchwork D1747: repoview: add visibilityexception argument to filterrevs() and related fns

login
register
mail settings
Submitter phabricator
Date Dec. 25, 2017, 3:08 p.m.
Message ID <af246116e6e2e574317bedd3462a9b9c@localhost.localdomain>
Download mbox | patch
Permalink /patch/26432/
State Not Applicable
Headers show

Comments

phabricator - Dec. 25, 2017, 3:08 p.m.
pulkit updated this revision to Diff 4607.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1747?vs=4582&id=4607

REVISION DETAIL
  https://phab.mercurial-scm.org/D1747

AFFECTED FILES
  mercurial/repoview.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -65,24 +65,26 @@ 
                 hidden.remove(p)
                 stack.append(p)
 
-def computehidden(repo):
+def computehidden(repo, visibilityexceptions=None):
     """compute the set of hidden revision to filter
 
     During most operation hidden should be filtered."""
     assert not repo.changelog.filteredrevs
 
     hidden = hideablerevs(repo)
     if hidden:
         hidden = set(hidden - pinnedrevs(repo))
+        if visibilityexceptions:
+            hidden -= visibilityexceptions
         pfunc = repo.changelog.parentrevs
         mutablephases = (phases.draft, phases.secret)
         mutable = repo._phasecache.getrevset(repo, mutablephases)
 
         visible = mutable - hidden
         _revealancestors(pfunc, hidden, visible)
     return frozenset(hidden)
 
-def computeunserved(repo):
+def computeunserved(repo, visibilityexceptions=None):
     """compute the set of revision that should be filtered when used a server
 
     Secret and hidden changeset should not pretend to be here."""
@@ -100,16 +102,16 @@ 
     else:
         return hiddens
 
-def computemutable(repo):
+def computemutable(repo, visibilityexceptions=None):
     assert not repo.changelog.filteredrevs
     # fast check to avoid revset call on huge repo
     if any(repo._phasecache.phaseroots[1:]):
         getphase = repo._phasecache.phase
         maymutable = filterrevs(repo, 'base')
         return frozenset(r for r in maymutable if getphase(repo, r))
     return frozenset()
 
-def computeimpactable(repo):
+def computeimpactable(repo, visibilityexceptions=None):
     """Everything impactable by mutable revision
 
     The immutable filter still have some chance to get invalidated. This will
@@ -145,10 +147,16 @@ 
                'immutable':  computemutable,
                'base':  computeimpactable}
 
-def filterrevs(repo, filtername):
-    """returns set of filtered revision for this filter name"""
+def filterrevs(repo, filtername, visibilityexceptions=None):
+    """returns set of filtered revision for this filter name
+
+    visibilityexceptions is a set of revs which must are exceptions for
+    hidden-state and must be visible. They are dynamic and hence we should not
+    cache it's result"""
     if filtername not in repo.filteredrevcache:
         func = filtertable[filtername]
+        if visibilityexceptions:
+            return func(repo.unfiltered, visibilityexceptions)
         repo.filteredrevcache[filtername] = func(repo.unfiltered())
     return repo.filteredrevcache[filtername]
 
@@ -210,7 +218,7 @@ 
         unfilen = len(unfiindex) - 1
         unfinode = unfiindex[unfilen - 1][7]
 
-        revs = filterrevs(unfi, self.filtername)
+        revs = filterrevs(unfi, self.filtername, self._visibilityexceptions)
         cl = self._clcache
         newkey = (unfilen, unfinode, hash(revs), unfichangelog._delayed)
         # if cl.index is not unfiindex, unfi.changelog would be