repoview: add visibilityexceptions as an optional argument to repo.filtered()
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 22 Dec 2017 17:57:11 +0530
changeset 41303 3ad582b2895cfd814bd9383d49256483caa20229
parent 41302 ded3a63f305b5144400c9925d1cc6e2bc8a46a6d
child 41304 3c9c05a38d78a54c21cb0f397099a3dafd69547f
push id637
push usergszorc@mozilla.com
push dateThu, 28 Dec 2017 00:11:26 +0000
repoview: add visibilityexceptions as an optional argument to repo.filtered() This will help us in having an API where we can pass the filtername and the visibilityexceptions to get a new repo object. Visibility exceptions are the revs which must be visible even they should in theory belong to the hidden set. They are required as there has been desire to have a functionality to access hidden changesets using certain commands without passing --hidden. After this patch we can make those changesets visibility exceptions so that we can access them without requiring a unfiltered repo. Differential Revision: https://phab.mercurial-scm.org/D1746
mercurial/localrepo.py
mercurial/repoview.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -670,20 +670,20 @@ class localrepository(object):
         return localpeer(self) # not cached to avoid reference cycle
 
     def unfiltered(self):
         """Return unfiltered version of the repository
 
         Intended to be overwritten by filtered repo."""
         return self
 
-    def filtered(self, name):
+    def filtered(self, name, visibilityexceptions=None):
         """Return a filtered version of a repository"""
         cls = repoview.newtype(self.unfiltered().__class__)
-        return cls(self, name)
+        return cls(self, name, visibilityexceptions)
 
     @repofilecache('bookmarks', 'bookmarks.current')
     def _bookmarks(self):
         return bookmarks.bmstore(self)
 
     @property
     def _activebookmark(self):
         return self._bookmarks.active
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -182,21 +182,24 @@ class repoview(object):
     leads to the property below.
 
         repoview.method() --> repo.__class__.method(repoview)
 
     The inheritance has to be done dynamically because `repo` can be of any
     subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`.
     """
 
-    def __init__(self, repo, filtername):
+    def __init__(self, repo, filtername, visibilityexceptions=None):
         object.__setattr__(self, r'_unfilteredrepo', repo)
         object.__setattr__(self, r'filtername', filtername)
         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)
 
     # not a propertycache on purpose we shall implement a proper cache later
     @property
     def changelog(self):
         """return a filtered version of the changeset
 
         this changelog must not be used for writing"""
         # some cache may be implemented later
@@ -222,21 +225,21 @@ class repoview(object):
             object.__setattr__(self, r'_clcache', cl)
             object.__setattr__(self, r'_clcachekey', newkey)
         return cl
 
     def unfiltered(self):
         """Return an unfiltered version of a repo"""
         return self._unfilteredrepo
 
-    def filtered(self, name):
+    def filtered(self, name, visibilityexceptions=None):
         """Return a filtered version of a repository"""
-        if name == self.filtername:
+        if name == self.filtername and not visibilityexceptions:
             return self
-        return self.unfiltered().filtered(name)
+        return self.unfiltered().filtered(name, visibilityexceptions)
 
     def __repr__(self):
         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):