mercurial/localrepo.py
changeset 18644 3e92772d5383
parent 18520 751135cca13c
child 18659 b946470efed9
equal deleted inserted replaced
18643:cc28a84db8c9 18644:3e92772d5383
    47     def cachevalue(self, obj, value):
    47     def cachevalue(self, obj, value):
    48         object.__setattr__(obj, self.name, value)
    48         object.__setattr__(obj, self.name, value)
    49 
    49 
    50 
    50 
    51 def hasunfilteredcache(repo, name):
    51 def hasunfilteredcache(repo, name):
    52     """check if an repo and a unfilteredproperty cached value for <name>"""
    52     """check if a repo has an unfilteredpropertycache value for <name>"""
    53     return name in vars(repo.unfiltered())
    53     return name in vars(repo.unfiltered())
    54 
    54 
    55 def unfilteredmethod(orig):
    55 def unfilteredmethod(orig):
    56     """decorate method that always need to be run on unfiltered version"""
    56     """decorate method that always need to be run on unfiltered version"""
    57     def wrapper(repo, *args, **kwargs):
    57     def wrapper(repo, *args, **kwargs):
   308         return localpeer(self) # not cached to avoid reference cycle
   308         return localpeer(self) # not cached to avoid reference cycle
   309 
   309 
   310     def unfiltered(self):
   310     def unfiltered(self):
   311         """Return unfiltered version of the repository
   311         """Return unfiltered version of the repository
   312 
   312 
   313         Intended to be ovewritten by filtered repo."""
   313         Intended to be overwritten by filtered repo."""
   314         return self
   314         return self
   315 
   315 
   316     def filtered(self, name):
   316     def filtered(self, name):
   317         """Return a filtered version of a repository"""
   317         """Return a filtered version of a repository"""
   318         # build a new class with the mixin and the current class
   318         # build a new class with the mixin and the current class
   319         # (possibily subclass of the repo)
   319         # (possibly subclass of the repo)
   320         class proxycls(repoview.repoview, self.unfiltered().__class__):
   320         class proxycls(repoview.repoview, self.unfiltered().__class__):
   321             pass
   321             pass
   322         return proxycls(self, name)
   322         return proxycls(self, name)
   323 
   323 
   324     @repofilecache('bookmarks')
   324     @repofilecache('bookmarks')
   960                 except AttributeError:
   960                 except AttributeError:
   961                     pass
   961                     pass
   962             delattr(self.unfiltered(), 'dirstate')
   962             delattr(self.unfiltered(), 'dirstate')
   963 
   963 
   964     def invalidate(self):
   964     def invalidate(self):
   965         unfiltered = self.unfiltered() # all filecaches are stored on unfiltered
   965         unfiltered = self.unfiltered() # all file caches are stored unfiltered
   966         for k in self._filecache:
   966         for k in self._filecache:
   967             # dirstate is invalidated separately in invalidatedirstate()
   967             # dirstate is invalidated separately in invalidatedirstate()
   968             if k == 'dirstate':
   968             if k == 'dirstate':
   969                 continue
   969                 continue
   970 
   970 
  1395     @unfilteredmethod
  1395     @unfilteredmethod
  1396     def destroyed(self):
  1396     def destroyed(self):
  1397         '''Inform the repository that nodes have been destroyed.
  1397         '''Inform the repository that nodes have been destroyed.
  1398         Intended for use by strip and rollback, so there's a common
  1398         Intended for use by strip and rollback, so there's a common
  1399         place for anything that has to be done after destroying history.
  1399         place for anything that has to be done after destroying history.
  1400 
       
  1401         If you know the branchheadcache was uptodate before nodes were removed
       
  1402         and you also know the set of candidate new heads that may have resulted
       
  1403         from the destruction, you can set newheadnodes.  This will enable the
       
  1404         code to update the branchheads cache, rather than having future code
       
  1405         decide it's invalid and regenerating it from scratch.
       
  1406         '''
  1400         '''
  1407         # When one tries to:
  1401         # When one tries to:
  1408         # 1) destroy nodes thus calling this method (e.g. strip)
  1402         # 1) destroy nodes thus calling this method (e.g. strip)
  1409         # 2) use phasecache somewhere (e.g. commit)
  1403         # 2) use phasecache somewhere (e.g. commit)
  1410         #
  1404         #
  1415         if '_phasecache' in self._filecache:
  1409         if '_phasecache' in self._filecache:
  1416             self._phasecache.filterunknown(self)
  1410             self._phasecache.filterunknown(self)
  1417             self._phasecache.write()
  1411             self._phasecache.write()
  1418 
  1412 
  1419         # update the 'served' branch cache to help read only server process
  1413         # update the 'served' branch cache to help read only server process
  1420         # Thanks to branchcach collaboration this is done from the nearest
  1414         # Thanks to branchcache collaboration this is done from the nearest
  1421         # filtered subset and it is expected to be fast.
  1415         # filtered subset and it is expected to be fast.
  1422         branchmap.updatecache(self.filtered('served'))
  1416         branchmap.updatecache(self.filtered('served'))
  1423 
  1417 
  1424         # Ensure the persistent tag cache is updated.  Doing it now
  1418         # Ensure the persistent tag cache is updated.  Doing it now
  1425         # means that the tag cache only has to worry about destroyed
  1419         # means that the tag cache only has to worry about destroyed