[PATCH 3 of 5 filtering part 2] clfilter: add a cache on repo for set of revision to filter for a given set

Pierre-Yves David pierre-yves.david at logilab.fr
Fri Dec 7 08:23:40 CST 2012


On Tue, Dec 04, 2012 at 01:26:56AM +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1354389187 -3600
> # Node ID 6c38bdbce9bcbd96fd23476561f1443c17c18d6f
> # Parent  e1e4bc0047f35958b6dbdb8dca10e81b60bbb223
> 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.
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -61,11 +61,14 @@ def unfilteredmethod(orig):
>  # function to compute filtered set
>  computefiltered = {}
>  
>  def _filteredrevs(repo, filtername):
>      """returns set of filtered revision for this filter name"""
> -    return computefiltered[filtername](repo.unfiltered())
> +    if filtername not in repo.revsfiltercache:
> +        func = computefiltered[filtername]
> +        repo.revsfiltercache[filtername] = func(repo.unfiltered())
> +    return repo.revsfiltercache[filtername]
>  
>  class repoproxy(object):
>      """Changelog filterered localrepo proxy object
>  
>      This object act is a proxy for attribute operation. setattr is done on the
> @@ -301,10 +304,19 @@ class localrepository(object):
>          # (used by the filecache decorator)
>          #
>          # Maps a property name to its util.filecacheentry
>          self._filecache = {}
>  
> +        # hold sets of revision t
> +        # should be cleared when
> +        # - new changesets,
> +        # - phase change,
> +        # - new obsolescence mark
> +        # - working directory par
> +        # - bookmark changes
> +        self.revsfiltercache = {}
> +

Comment have be misteriously truncated: you can read the full version here:

    http://hg-lab.logilab.org/wip/hg/rev/fa0778d07ece#l1.19


-- 
Pierre-Yves David

http://www.logilab.fr/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121207/18ded079/attachment.pgp>


More information about the Mercurial-devel mailing list