mercurial/repoview.py
changeset 43076 2372284d9457
parent 42231 d345627d104b
child 43077 687b865b95ad
--- a/mercurial/repoview.py	Sat Oct 05 10:29:34 2019 -0400
+++ b/mercurial/repoview.py	Sun Oct 06 09:45:02 2019 -0400
@@ -19,9 +19,8 @@
     tags as tagsmod,
     util,
 )
-from .utils import (
-    repoviewutil,
-)
+from .utils import repoviewutil
+
 
 def hideablerevs(repo):
     """Revision candidates to be hidden
@@ -37,6 +36,7 @@
     internals = frozenset(internals)
     return obsoletes | internals
 
+
 def pinnedrevs(repo):
     """revisions blocking hidden changesets from being filtered
     """
@@ -72,6 +72,7 @@
                 hidden.remove(p)
                 stack.append(p)
 
+
 def computehidden(repo, visibilityexceptions=None):
     """compute the set of hidden revision to filter
 
@@ -90,6 +91,7 @@
         _revealancestors(pfunc, hidden, visible)
     return frozenset(hidden)
 
+
 def computesecret(repo, visibilityexceptions=None):
     """compute the set of revision that can never be exposed through hgweb
 
@@ -98,6 +100,7 @@
     secrets = repo._phasecache.getrevset(repo, phases.remotehiddenphases)
     return frozenset(secrets)
 
+
 def computeunserved(repo, visibilityexceptions=None):
     """compute the set of revision that should be filtered when used a server
 
@@ -111,6 +114,7 @@
     else:
         return hiddens
 
+
 def computemutable(repo, visibilityexceptions=None):
     assert not repo.changelog.filteredrevs
     # fast check to avoid revset call on huge repo
@@ -120,6 +124,7 @@
         return frozenset(r for r in maymutable if getphase(repo, r))
     return frozenset()
 
+
 def computeimpactable(repo, visibilityexceptions=None):
     """Everything impactable by mutable revision
 
@@ -145,21 +150,25 @@
     firstmutable = max(0, firstmutable)
     return frozenset(pycompat.xrange(firstmutable, len(cl)))
 
+
 # function to compute filtered set
 #
 # When adding a new filter you MUST update the table at:
 #     mercurial.utils.repoviewutil.subsettable
 # Otherwise your filter will have to recompute all its branches cache
 # from scratch (very slow).
-filtertable = {'visible': computehidden,
-               'visible-hidden': computehidden,
-               'served.hidden': computesecret,
-               'served': computeunserved,
-               'immutable':  computemutable,
-               'base':  computeimpactable}
+filtertable = {
+    'visible': computehidden,
+    'visible-hidden': computehidden,
+    'served.hidden': computesecret,
+    'served': computeunserved,
+    'immutable': computemutable,
+    'base': computeimpactable,
+}
 
 _basefiltername = list(filtertable)
 
+
 def extrafilter(ui):
     """initialize extra filter and return its id
 
@@ -178,15 +187,18 @@
 
     if combine('base') not in filtertable:
         for name in _basefiltername:
+
             def extrafilteredrevs(repo, *args, **kwargs):
                 baserevs = filtertable[name](repo, *args, **kwargs)
                 extrarevs = frozenset(repo.revs(frevs))
                 return baserevs | extrarevs
+
             filtertable[combine(name)] = extrafilteredrevs
             if name in subsettable:
                 subsettable[combine(name)] = combine(subsettable[name])
     return fid
 
+
 def filterrevs(repo, filtername, visibilityexceptions=None):
     """returns set of filtered revision for this filter name
 
@@ -200,6 +212,7 @@
         repo.filteredrevcache[filtername] = func(repo.unfiltered())
     return repo.filteredrevcache[filtername]
 
+
 class repoview(object):
     """Provide a read/write view of a repo through a filtered changelog
 
@@ -241,8 +254,7 @@
         object.__setattr__(self, r'_clcachekey', None)
         object.__setattr__(self, r'_clcache', None)
         # revs which are exceptions and must not be hidden
-        object.__setattr__(self, r'_visibilityexceptions',
-                           visibilityexceptions)
+        object.__setattr__(self, r'_visibilityexceptions', visibilityexceptions)
 
     # not a propertycache on purpose we shall implement a proper cache later
     @property
@@ -263,8 +275,9 @@
         newkey = (unfilen, unfinode, hash(revs), unfichangelog._delayed)
         # if cl.index is not unfiindex, unfi.changelog would be
         # recreated, and our clcache refers to garbage object
-        if (cl is not None and
-            (cl.index is not unfiindex or newkey != self._clcachekey)):
+        if cl is not None and (
+            cl.index is not unfiindex or newkey != self._clcachekey
+        ):
             cl = None
         # could have been made None by the previous if
         if cl is None:
@@ -285,9 +298,11 @@
         return self.unfiltered().filtered(name, visibilityexceptions)
 
     def __repr__(self):
-        return r'<%s:%s %r>' % (self.__class__.__name__,
-                                pycompat.sysstr(self.filtername),
-                                self.unfiltered())
+        return r'<%s:%s %r>' % (
+            self.__class__.__name__,
+            pycompat.sysstr(self.filtername),
+            self.unfiltered(),
+        )
 
     # everything access are forwarded to the proxied repo
     def __getattr__(self, attr):
@@ -299,15 +314,19 @@
     def __delattr__(self, attr):
         return delattr(self._unfilteredrepo, attr)
 
+
 # Python <3.4 easily leaks types via __mro__. See
 # https://bugs.python.org/issue17950. We cache dynamically created types
 # so they won't be leaked on every invocation of repo.filtered().
 _filteredrepotypes = weakref.WeakKeyDictionary()
 
+
 def newtype(base):
     """Create a new type with the repoview mixin and the given base class"""
     if base not in _filteredrepotypes:
+
         class filteredrepo(repoview, base):
             pass
+
         _filteredrepotypes[base] = filteredrepo
     return _filteredrepotypes[base]