D1492: repoview: take out the logic of computehidden to a new function

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Nov 22 20:24:14 EST 2017


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We are going to use that logic in compute functions for the new filternames
  which will be introduced in the next patch. So lets make a utility function
  which takes filtername and can be used by related compute functions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/repoview.py

CHANGE DETAILS

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -63,24 +63,27 @@
                 hidden.remove(p)
                 stack.append(p)
 
-def computehidden(repo):
-    """compute the set of hidden revision to filter
-
-    During most operation hidden should be filtered."""
-    assert not repo.changelog.filteredrevs
-
+def _computeperfiltername(repo, filtername):
+    """computes the set of revisions to filter for visible* filters"""
     hidden = hideablerevs(repo)
     if hidden:
         hidden = set(hidden - pinnedrevs(repo))
-        hidden = hidden - repo.filtered('visible').getvisibilityexceptions()
+        hidden = hidden - repo.filtered(filtername).getvisibilityexceptions()
         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 computehidden(repo):
+    """compute the set of hidden revision to filter
+
+    During most operation hidden should be filtered."""
+    assert not repo.changelog.filteredrevs
+    return _computeperfiltername(repo, 'visible')
+
 def computeunserved(repo):
     """compute the set of revision that should be filtered when used a server
 



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


More information about the Mercurial-devel mailing list