mercurial/localrepo.py
changeset 18114 35ce17796e0e
parent 18113 da1714bd0250
child 18117 526e7ec5c96e
equal deleted inserted replaced
18113:da1714bd0250 18114:35ce17796e0e
   659         better alternative. But we are using this approach until it is ready.
   659         better alternative. But we are using this approach until it is ready.
   660         """
   660         """
   661         cl = self.changelog
   661         cl = self.changelog
   662         return cl.rev(cl.tip())
   662         return cl.rev(cl.tip())
   663 
   663 
   664     def _branchtags(self, partial, lrev):
   664     @unfilteredmethod # Until we get a smarter cache management
   665         # TODO: rename this function?
   665     def updatebranchcache(self):
   666         cl = self.changelog
   666         cl = self.changelog
       
   667         tip = cl.tip()
       
   668         if self._branchcache is not None and self._branchcachetip == tip:
       
   669             return
       
   670 
       
   671         oldtip = self._branchcachetip
       
   672         if oldtip is None or oldtip not in cl.nodemap:
       
   673             partial, last, lrev = self._readbranchcache()
       
   674         else:
       
   675             lrev = cl.rev(oldtip)
       
   676             partial = self._branchcache
       
   677 
   667         catip = self._cacheabletip()
   678         catip = self._cacheabletip()
   668         # if lrev == catip: cache is already up to date
   679         # if lrev == catip: cache is already up to date
   669         # if lrev >  catip: we have uncachable element in `partial` can't write
   680         # if lrev >  catip: we have uncachable element in `partial` can't write
   670         #                   on disk
   681         #                   on disk
   671         if lrev < catip:
   682         if lrev < catip:
   678         # written to disk since it's not cacheable.
   689         # written to disk since it's not cacheable.
   679         tiprev = len(self) - 1
   690         tiprev = len(self) - 1
   680         if lrev < tiprev:
   691         if lrev < tiprev:
   681             ctxgen = (self[r] for r in cl.revs(lrev + 1, tiprev))
   692             ctxgen = (self[r] for r in cl.revs(lrev + 1, tiprev))
   682             self._updatebranchcache(partial, ctxgen)
   693             self._updatebranchcache(partial, ctxgen)
   683         return partial
   694         self._branchcache = partial
   684 
       
   685     @unfilteredmethod # Until we get a smarter cache management
       
   686     def updatebranchcache(self):
       
   687         cl = self.changelog
       
   688         tip = cl.tip()
       
   689         if self._branchcache is not None and self._branchcachetip == tip:
       
   690             return
       
   691 
       
   692         oldtip = self._branchcachetip
       
   693         self._branchcachetip = tip
   695         self._branchcachetip = tip
   694         if oldtip is None or oldtip not in cl.nodemap:
       
   695             partial, last, lrev = self._readbranchcache()
       
   696         else:
       
   697             lrev = cl.rev(oldtip)
       
   698             partial = self._branchcache
       
   699 
       
   700         self._branchtags(partial, lrev)
       
   701         # this private cache holds all heads (not just the branch tips)
       
   702         self._branchcache = partial
       
   703 
   696 
   704     def branchmap(self):
   697     def branchmap(self):
   705         '''returns a dictionary {branch: [branchheads]}'''
   698         '''returns a dictionary {branch: [branchheads]}'''
   706         if self.changelog.filteredrevs:
   699         if self.changelog.filteredrevs:
   707             # some changeset are excluded we can't use the cache
   700             # some changeset are excluded we can't use the cache