Mercurial > hg
comparison mercurial/repoview.py @ 35492:3ad582b2895c
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
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 22 Dec 2017 17:57:11 +0530 |
parents | d4ad9d695a9e |
children | 3c9c05a38d78 |
comparison
equal
deleted
inserted
replaced
35491:ded3a63f305b | 35492:3ad582b2895c |
---|---|
185 | 185 |
186 The inheritance has to be done dynamically because `repo` can be of any | 186 The inheritance has to be done dynamically because `repo` can be of any |
187 subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`. | 187 subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`. |
188 """ | 188 """ |
189 | 189 |
190 def __init__(self, repo, filtername): | 190 def __init__(self, repo, filtername, visibilityexceptions=None): |
191 object.__setattr__(self, r'_unfilteredrepo', repo) | 191 object.__setattr__(self, r'_unfilteredrepo', repo) |
192 object.__setattr__(self, r'filtername', filtername) | 192 object.__setattr__(self, r'filtername', filtername) |
193 object.__setattr__(self, r'_clcachekey', None) | 193 object.__setattr__(self, r'_clcachekey', None) |
194 object.__setattr__(self, r'_clcache', None) | 194 object.__setattr__(self, r'_clcache', None) |
195 # revs which are exceptions and must not be hidden | |
196 object.__setattr__(self, r'_visibilityexceptions', | |
197 visibilityexceptions) | |
195 | 198 |
196 # not a propertycache on purpose we shall implement a proper cache later | 199 # not a propertycache on purpose we shall implement a proper cache later |
197 @property | 200 @property |
198 def changelog(self): | 201 def changelog(self): |
199 """return a filtered version of the changeset | 202 """return a filtered version of the changeset |
225 | 228 |
226 def unfiltered(self): | 229 def unfiltered(self): |
227 """Return an unfiltered version of a repo""" | 230 """Return an unfiltered version of a repo""" |
228 return self._unfilteredrepo | 231 return self._unfilteredrepo |
229 | 232 |
230 def filtered(self, name): | 233 def filtered(self, name, visibilityexceptions=None): |
231 """Return a filtered version of a repository""" | 234 """Return a filtered version of a repository""" |
232 if name == self.filtername: | 235 if name == self.filtername and not visibilityexceptions: |
233 return self | 236 return self |
234 return self.unfiltered().filtered(name) | 237 return self.unfiltered().filtered(name, visibilityexceptions) |
235 | 238 |
236 def __repr__(self): | 239 def __repr__(self): |
237 return r'<%s:%s %r>' % (self.__class__.__name__, | 240 return r'<%s:%s %r>' % (self.__class__.__name__, |
238 pycompat.sysstr(self.filtername), | 241 pycompat.sysstr(self.filtername), |
239 self.unfiltered()) | 242 self.unfiltered()) |