[PATCH 21 of 27 clfilter V2] clfilter: add a cache on repo for set of revision to filter for a given set
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Mon Oct 8 16:38:12 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1349717157 -7200
# Node ID 412d0319e39b958de80d2a25b0218164ef6f8160
# Parent d0ef65c1a9eb2569ba3333ee88edea6cb2bfafaf
clfilter: add a cache on repo for set of revision to filter for a given set.
We can't recompute it every time. This changeset contains both cache
initialization and invalidation logic.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -62,7 +62,10 @@
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 repoproxier(object):
"""Changelog filterered localrepo proxy object
@@ -304,6 +307,15 @@
# 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 = {}
+
def close(self):
pass
@@ -1169,6 +1181,7 @@
self.unfiltered()._branchcache = None # in UTF-8
self.unfiltered()._branchcachetip = None
obsolete.clearobscaches(self)
+ self.revsfiltercache.clear()
def invalidatedirstate(self):
'''Invalidates the dirstate, causing the next call to dirstate
@@ -1934,6 +1947,7 @@
if key.startswith('dump'):
data = base85.b85decode(remoteobs[key])
self.obsstore.mergemarkers(tr, data)
+ self.revsfiltercache.clear()
if tr is not None:
tr.close()
finally:
@@ -2540,6 +2554,7 @@
" with %d changes to %d files%s\n")
% (changesets, revisions, files, htext))
obsolete.clearobscaches(self)
+ self.revsfiltercache.clear()
if changesets > 0:
p = lambda: cl.writepending() and self.root or ""
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -429,6 +429,7 @@
if nprec in nsucs:
raise util.Abort("changeset %s cannot obsolete itself" % prec)
repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
+ repo.revsfiltercache.clear()
tr.close()
finally:
tr.release()
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -249,6 +249,7 @@
if targetphase != 0:
self.retractboundary(repo, targetphase, delroots)
obsolete.clearobscaches(repo)
+ repo.revsfiltercache.clear()
def retractboundary(self, repo, targetphase, nodes):
# Be careful to preserve shallow-copied values: do not update
@@ -267,6 +268,7 @@
currentroots.intersection_update(ctx.node() for ctx in ctxs)
self._updateroots(targetphase, currentroots)
obsolete.clearobscaches(repo)
+ repo.revsfiltercache.clear()
def advanceboundary(repo, targetphase, nodes):
"""Add nodes to a phase changing other nodes phases if necessary.
More information about the Mercurial-devel
mailing list