Patchwork D1730: repoview: store visibility exceptions for the filter in filtertable

login
register
mail settings
Submitter phabricator
Date Dec. 19, 2017, 12:09 p.m.
Message ID <differential-rev-PHID-DREV-jiha5z54wuhl4nshiose-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26356/
State Superseded
Headers show

Comments

phabricator - Dec. 19, 2017, 12:09 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Earlier, filtertable contains the filtername and the corresponding function to
  calculate filtered set for that filter. This patch make filtertable also store
  the visibility exceptions for that filter. filtertable was a dictionary with
  filtername as the key and function as the value, after this patch, the value is
  a tuple of form `(fn, visibilityexceptions)`.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/repoview.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 19, 2017, 2:05 p.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> repoview.py:145
>  # from scratch (very slow).
> -filtertable = {'visible': computehidden,
> -               'served': computeunserved,
> -               'immutable':  computemutable,
> -               'base':  computeimpactable}
> +filtertable = {'visible': (computehidden, set()),
> +               'served': (computeunserved, set()),

So this is global across repositories and permanently cached.

Can't we store the "exceptions" in repoview? I think their lifetime
should be the same.

REPOSITORY
  rHG Mercurial

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

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
@@ -134,22 +136,23 @@ 
     firstmutable = max(0, firstmutable)
     return frozenset(xrange(firstmutable, len(cl)))
 
-# function to compute filtered set
+# function and visibility exceptions to compute filtered set
 #
 # When adding a new filter you MUST update the table at:
 #     mercurial.branchmap.subsettable
 # Otherwise your filter will have to recompute all its branches cache
 # from scratch (very slow).
-filtertable = {'visible': computehidden,
-               'served': computeunserved,
-               'immutable':  computemutable,
-               'base':  computeimpactable}
+filtertable = {'visible': (computehidden, set()),
+               'served': (computeunserved, set()),
+               'immutable': (computemutable, set()),
+               'base': (computeimpactable, set())}
 
 def filterrevs(repo, filtername):
     """returns set of filtered revision for this filter name"""
     if filtername not in repo.filteredrevcache:
-        func = filtertable[filtername]
-        repo.filteredrevcache[filtername] = func(repo.unfiltered())
+        func, visibilityexceptions = filtertable[filtername]
+        repo.filteredrevcache[filtername] = func(repo.unfiltered(),
+                                                 visibilityexceptions)
     return repo.filteredrevcache[filtername]
 
 class repoview(object):