mercurial/localrepo.py
changeset 52643 5cc8deb96b48
parent 52640 24ee91ba9aa8
child 52654 f19a3f1437f3
equal deleted inserted replaced
52642:73ab542565e0 52643:5cc8deb96b48
   122         unfi = repo.unfiltered()
   122         unfi = repo.unfiltered()
   123         try:
   123         try:
   124             return unfi.__dict__[self.sname]
   124             return unfi.__dict__[self.sname]
   125         except KeyError:
   125         except KeyError:
   126             pass
   126             pass
   127         return super(_basefilecache, self).__get__(unfi, type)
   127         return super().__get__(unfi, type)
   128 
   128 
   129     def set(self, repo, value):
   129     def set(self, repo, value):
   130         return super(_basefilecache, self).set(repo.unfiltered(), value)
   130         return super().set(repo.unfiltered(), value)
   131 
   131 
   132 
   132 
   133 class repofilecache(_basefilecache):
   133 class repofilecache(_basefilecache):
   134     """filecache for files in .hg but outside of .hg/store"""
   134     """filecache for files in .hg but outside of .hg/store"""
   135 
   135 
   136     def __init__(self, *paths):
   136     def __init__(self, *paths):
   137         super(repofilecache, self).__init__(*paths)
   137         super().__init__(*paths)
   138         for path in paths:
   138         for path in paths:
   139             _cachedfiles.add((path, b'plain'))
   139             _cachedfiles.add((path, b'plain'))
   140 
   140 
   141     def join(self, obj, fname):
   141     def join(self, obj, fname):
   142         return obj.vfs.join(fname)
   142         return obj.vfs.join(fname)
   144 
   144 
   145 class storecache(_basefilecache):
   145 class storecache(_basefilecache):
   146     """filecache for files in the store"""
   146     """filecache for files in the store"""
   147 
   147 
   148     def __init__(self, *paths):
   148     def __init__(self, *paths):
   149         super(storecache, self).__init__(*paths)
   149         super().__init__(*paths)
   150         for path in paths:
   150         for path in paths:
   151             _cachedfiles.add((path, b''))
   151             _cachedfiles.add((path, b''))
   152 
   152 
   153     def join(self, obj, fname):
   153     def join(self, obj, fname):
   154         return obj.sjoin(fname)
   154         return obj.sjoin(fname)
   156 
   156 
   157 class changelogcache(storecache):
   157 class changelogcache(storecache):
   158     """filecache for the changelog"""
   158     """filecache for the changelog"""
   159 
   159 
   160     def __init__(self):
   160     def __init__(self):
   161         super(changelogcache, self).__init__()
   161         super().__init__()
   162         _cachedfiles.add((b'00changelog.i', b''))
   162         _cachedfiles.add((b'00changelog.i', b''))
   163         _cachedfiles.add((b'00changelog.n', b''))
   163         _cachedfiles.add((b'00changelog.n', b''))
   164 
   164 
   165     def tracked_paths(self, obj):
   165     def tracked_paths(self, obj):
   166         paths = [self.join(obj, b'00changelog.i')]
   166         paths = [self.join(obj, b'00changelog.i')]
   171 
   171 
   172 class manifestlogcache(storecache):
   172 class manifestlogcache(storecache):
   173     """filecache for the manifestlog"""
   173     """filecache for the manifestlog"""
   174 
   174 
   175     def __init__(self):
   175     def __init__(self):
   176         super(manifestlogcache, self).__init__()
   176         super().__init__()
   177         _cachedfiles.add((b'00manifest.i', b''))
   177         _cachedfiles.add((b'00manifest.i', b''))
   178         _cachedfiles.add((b'00manifest.n', b''))
   178         _cachedfiles.add((b'00manifest.n', b''))
   179 
   179 
   180     def tracked_paths(self, obj):
   180     def tracked_paths(self, obj):
   181         paths = [self.join(obj, b'00manifest.i')]
   181         paths = [self.join(obj, b'00manifest.i')]
   188     """filecache for a mix files in .hg/store and outside"""
   188     """filecache for a mix files in .hg/store and outside"""
   189 
   189 
   190     def __init__(self, *pathsandlocations):
   190     def __init__(self, *pathsandlocations):
   191         # scmutil.filecache only uses the path for passing back into our
   191         # scmutil.filecache only uses the path for passing back into our
   192         # join(), so we can safely pass a list of paths and locations
   192         # join(), so we can safely pass a list of paths and locations
   193         super(mixedrepostorecache, self).__init__(*pathsandlocations)
   193         super().__init__(*pathsandlocations)
   194         _cachedfiles.update(pathsandlocations)
   194         _cachedfiles.update(pathsandlocations)
   195 
   195 
   196     def join(self, obj, fnameandlocation):
   196     def join(self, obj, fnameandlocation):
   197         fname, location = fnameandlocation
   197         fname, location = fnameandlocation
   198         if location == b'plain':
   198         if location == b'plain':
   220     """propertycache that apply to unfiltered repo only"""
   220     """propertycache that apply to unfiltered repo only"""
   221 
   221 
   222     def __get__(self, repo, type=None):
   222     def __get__(self, repo, type=None):
   223         unfi = repo.unfiltered()
   223         unfi = repo.unfiltered()
   224         if unfi is repo:
   224         if unfi is repo:
   225             return super(unfilteredpropertycache, self).__get__(unfi)
   225             return super().__get__(unfi)
   226         return getattr(unfi, self.name)
   226         return getattr(unfi, self.name)
   227 
   227 
   228 
   228 
   229 class filteredpropertycache(util.propertycache):
   229 class filteredpropertycache(util.propertycache):
   230     """propertycache that must take filtering in account"""
   230     """propertycache that must take filtering in account"""
   306 
   306 
   307 class localpeer(repository.peer):  # (repository.ipeercommands)
   307 class localpeer(repository.peer):  # (repository.ipeercommands)
   308     '''peer for a local repo; reflects only the most recent API'''
   308     '''peer for a local repo; reflects only the most recent API'''
   309 
   309 
   310     def __init__(self, repo, caps=None, path=None, remotehidden=False):
   310     def __init__(self, repo, caps=None, path=None, remotehidden=False):
   311         super(localpeer, self).__init__(
   311         super().__init__(repo.ui, path=path, remotehidden=remotehidden)
   312             repo.ui, path=path, remotehidden=remotehidden
       
   313         )
       
   314 
   312 
   315         if caps is None:
   313         if caps is None:
   316             caps = moderncaps.copy()
   314             caps = moderncaps.copy()
   317         if remotehidden:
   315         if remotehidden:
   318             self._repo = repo.filtered(b'served.hidden')
   316             self._repo = repo.filtered(b'served.hidden')
   465 class locallegacypeer(localpeer):  # (repository.ipeerlegacycommands)
   463 class locallegacypeer(localpeer):  # (repository.ipeerlegacycommands)
   466     """peer extension which implements legacy methods too; used for tests with
   464     """peer extension which implements legacy methods too; used for tests with
   467     restricted capabilities"""
   465     restricted capabilities"""
   468 
   466 
   469     def __init__(self, repo, path=None, remotehidden=False):
   467     def __init__(self, repo, path=None, remotehidden=False):
   470         super(locallegacypeer, self).__init__(
   468         super().__init__(
   471             repo, caps=legacycaps, path=path, remotehidden=remotehidden
   469             repo, caps=legacycaps, path=path, remotehidden=remotehidden
   472         )
   470         )
   473 
   471 
   474     # Begin of baselegacywirecommands interface.
   472     # Begin of baselegacywirecommands interface.
   475 
   473