Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 18189:b9026ba002f6
branchmap: enable caching for filtered version too
The `_branchcache` attribute is turned into a dictionary. Key are filter name and
value is a `branchcache` object. Unfiltered version is cached as `None` filter.
The attribute is renamed to `_branchcaches` to avoid confusion with the previous
one. Both old and new contents are dictionary even if their contents are
different. I prefer possible extension code to crash right away instead of just
messing the wrong dictionary.
As all different caches work isolated to each other, this code keeps the
previous behavior of using the unfiltered cache we nothing is filtered. This
is a cheap way to have cache collaborate and nullify potential impact in the
default case.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 24 Dec 2012 03:21:15 +0100 |
parents | d336f53cb2e3 |
children | c565761dde6a |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Jan 01 21:27:13 2013 +0100 +++ b/mercurial/localrepo.py Mon Dec 24 03:21:15 2012 +0100 @@ -229,7 +229,7 @@ self._writerequirements() - self._branchcache = None + self._branchcaches = {} self.filterpats = {} self._datafilters = {} self._transref = self._lockref = self._wlockref = None @@ -664,14 +664,10 @@ def branchmap(self): '''returns a dictionary {branch: [branchheads]}''' - if self.changelog.filteredrevs: - # some changeset are excluded we can't use the cache - bmap = branchmap.branchcache() - bmap.update(self, (self[r] for r in self)) - return bmap - else: - branchmap.updatecache(self) - return self._branchcache + if self.filtername and not self.changelog.filteredrevs: + return self.unfiltered().branchmap() + branchmap.updatecache(self) + return self._branchcaches[self.filtername] def _branchtip(self, heads): @@ -978,7 +974,7 @@ # can't use delattr on proxy del self.__dict__['_tagscache'] - self.unfiltered()._branchcache = None # in UTF-8 + self.unfiltered()._branchcaches.clear() self.invalidatevolatilesets() def invalidatevolatilesets(self): @@ -1437,7 +1433,7 @@ if newheadnodes: ctxgen = (self[node] for node in newheadnodes if self.changelog.hasnode(node)) - cache = self._branchcache + cache = self._branchcaches[None] cache.update(self, ctxgen) cache.write(self) @@ -2500,8 +2496,8 @@ cache = branchmap.branchcache(rbranchmap, self[rtiprev].node(), rtiprev) - self._branchcache = cache - cache.write(self) + self._branchcaches[None] = cache + cache.write(self.unfiltered()) self.invalidate() return len(self.heads()) + 1 finally: