comparison mercurial/repoview.py @ 18101:a464deecc9dd

clfilter: add a cache on repo for set of revision to filter for a given set. Recomputing the filtered revisions at every access to changelog is far too expensive. This changeset introduce a cache for this information. This cache is hold by the repository (unfiltered repository) and invalidated when necessary. This cache is not a protected attribute (leading _) because some logic that invalidate it is not held by the local repo itself.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 20 Dec 2012 17:14:07 +0100
parents 3a6ddacb7198
children 3c7b67b76190
comparison
equal deleted inserted replaced
18100:3a6ddacb7198 18101:a464deecc9dd
11 # function to compute filtered set 11 # function to compute filtered set
12 filtertable = {} 12 filtertable = {}
13 13
14 def filteredrevs(repo, filtername): 14 def filteredrevs(repo, filtername):
15 """returns set of filtered revision for this filter name""" 15 """returns set of filtered revision for this filter name"""
16 return filtertable[filtername](repo.unfiltered()) 16 if filtername not in repo.filteredrevcache:
17 func = filtertable[filtername]
18 repo.filteredrevcache[filtername] = func(repo.unfiltered())
19 return repo.filteredrevcache[filtername]
17 20
18 class repoview(object): 21 class repoview(object):
19 """Provide a read/write view of a repo through a filtered changelog 22 """Provide a read/write view of a repo through a filtered changelog
20 23
21 This object is used to access a filtered version of a repository without 24 This object is used to access a filtered version of a repository without