Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.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 | 46ed5226503a |
children | 493778b5fe9f |
comparison
equal
deleted
inserted
replaced
18188:46ed5226503a | 18189:b9026ba002f6 |
---|---|
57 return partial | 57 return partial |
58 | 58 |
59 | 59 |
60 | 60 |
61 def updatecache(repo): | 61 def updatecache(repo): |
62 repo = repo.unfiltered() # Until we get a smarter cache management | |
63 cl = repo.changelog | 62 cl = repo.changelog |
64 partial = repo._branchcache | 63 filtername = repo.filtername |
64 partial = repo._branchcaches.get(filtername) | |
65 | 65 |
66 if partial is None or not partial.validfor(repo): | 66 if partial is None or not partial.validfor(repo): |
67 partial = read(repo) | 67 partial = read(repo) |
68 | 68 |
69 catip = repo._cacheabletip() | 69 catip = repo._cacheabletip() |
79 # written to disk since it's not cacheable. | 79 # written to disk since it's not cacheable. |
80 tiprev = cl.rev(cl.tip()) | 80 tiprev = cl.rev(cl.tip()) |
81 if partial.tiprev < tiprev: | 81 if partial.tiprev < tiprev: |
82 ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, tiprev)) | 82 ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, tiprev)) |
83 partial.update(repo, ctxgen) | 83 partial.update(repo, ctxgen) |
84 repo._branchcache = partial | 84 repo._branchcaches[repo.filtername] = partial |
85 | 85 |
86 class branchcache(dict): | 86 class branchcache(dict): |
87 """A dict like object that hold branches heads cache""" | 87 """A dict like object that hold branches heads cache""" |
88 | 88 |
89 def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev, | 89 def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev, |