Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 41615:328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Rather than have a repository update the cache, move handling of cache updates
into the branchmap module, in the form of a custom mapping class.
This makes later performance improvements easier to handle too.
Differential Revision: https://phab.mercurial-scm.org/D5638
author | Martijn Pieters <mj@octobus.net> |
---|---|
date | Mon, 21 Jan 2019 17:37:33 +0000 |
parents | 13a6dd952ffe |
children | ddbebce94665 |
comparison
equal
deleted
inserted
replaced
41612:fbd4ce55bcbd | 41615:328ca3b9e545 |
---|---|
990 else: # standard vfs | 990 else: # standard vfs |
991 self.svfs.audit = self._getsvfsward(self.svfs.audit) | 991 self.svfs.audit = self._getsvfsward(self.svfs.audit) |
992 | 992 |
993 self._dirstatevalidatewarned = False | 993 self._dirstatevalidatewarned = False |
994 | 994 |
995 self._branchcaches = {} | 995 self._branchcaches = branchmap.BranchMapCache() |
996 self._revbranchcache = None | 996 self._revbranchcache = None |
997 self._filterpats = {} | 997 self._filterpats = {} |
998 self._datafilters = {} | 998 self._datafilters = {} |
999 self._transref = self._lockref = self._wlockref = None | 999 self._transref = self._lockref = self._wlockref = None |
1000 | 1000 |
1518 return self._bookmarks.names(node) | 1518 return self._bookmarks.names(node) |
1519 | 1519 |
1520 def branchmap(self): | 1520 def branchmap(self): |
1521 '''returns a dictionary {branch: [branchheads]} with branchheads | 1521 '''returns a dictionary {branch: [branchheads]} with branchheads |
1522 ordered by increasing revision number''' | 1522 ordered by increasing revision number''' |
1523 branchmap.updatecache(self) | 1523 return self._branchcaches[self] |
1524 return self._branchcaches[self.filtername] | |
1525 | 1524 |
1526 @unfilteredmethod | 1525 @unfilteredmethod |
1527 def revbranchcache(self): | 1526 def revbranchcache(self): |
1528 if not self._revbranchcache: | 1527 if not self._revbranchcache: |
1529 self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) | 1528 self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) |
2071 # During strip, many caches are invalid but | 2070 # During strip, many caches are invalid but |
2072 # later call to `destroyed` will refresh them. | 2071 # later call to `destroyed` will refresh them. |
2073 return | 2072 return |
2074 | 2073 |
2075 if tr is None or tr.changes['origrepolen'] < len(self): | 2074 if tr is None or tr.changes['origrepolen'] < len(self): |
2076 # updating the unfiltered branchmap should refresh all the others, | 2075 # accessing the 'ser ved' branchmap should refresh all the others, |
2077 self.ui.debug('updating the branch cache\n') | 2076 self.ui.debug('updating the branch cache\n') |
2078 branchmap.updatecache(self.filtered('served')) | 2077 self.filtered('served').branchmap() |
2079 | 2078 |
2080 if full: | 2079 if full: |
2081 rbc = self.revbranchcache() | 2080 rbc = self.revbranchcache() |
2082 for r in self.changelog: | 2081 for r in self.changelog: |
2083 rbc.branchinfo(r) | 2082 rbc.branchinfo(r) |
2091 | 2090 |
2092 if r'_tagscache' in vars(self): | 2091 if r'_tagscache' in vars(self): |
2093 # can't use delattr on proxy | 2092 # can't use delattr on proxy |
2094 del self.__dict__[r'_tagscache'] | 2093 del self.__dict__[r'_tagscache'] |
2095 | 2094 |
2096 self.unfiltered()._branchcaches.clear() | 2095 self._branchcaches.clear() |
2097 self.invalidatevolatilesets() | 2096 self.invalidatevolatilesets() |
2098 self._sparsesignaturecache.clear() | 2097 self._sparsesignaturecache.clear() |
2099 | 2098 |
2100 def invalidatevolatilesets(self): | 2099 def invalidatevolatilesets(self): |
2101 self.filteredrevcache.clear() | 2100 self.filteredrevcache.clear() |