[PATCH 03 of 11] localrepo: add a cache with stat info for files under .hg/
Idan Kamara
idankk86 at gmail.com
Sat Jul 16 09:34:34 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1310826866 -10800
# Node ID 87ba99602fd72793e5e9871bc3e775b4ddfffa57
# Parent b99305dd59279aec962e23da2a362e0d8b785965
localrepo: add a cache with stat info for files under .hg/
diff -r b99305dd5927 -r 87ba99602fd7 mercurial/localrepo.py
--- a/mercurial/localrepo.py Sat Jul 09 19:06:59 2011 +0300
+++ b/mercurial/localrepo.py Sat Jul 16 17:34:26 2011 +0300
@@ -110,6 +110,11 @@
self._datafilters = {}
self._transref = self._lockref = self._wlockref = None
+ # A cache for various files under .hg/ with stat info, used by the
+ # filecache decorator. Keys are the decorated function names, with
+ # [cached object, last stat info, path to watched file] as value.
+ self._invalidatecache = {}
+
def _applyrequirements(self, requirements):
self.requirements = requirements
openerreqs = set(('revlogv1', 'generaldelta'))
@@ -814,6 +819,19 @@
self._lockref = weakref.ref(l)
return l
+ def _updatestatinfo(self, key=None):
+ '''update stat info of the given key or all keys in the cache (except
+ dirstate)'''
+ if key:
+ e = self._invalidatecache[key]
+ e[1] = util.stat(e[2])
+ else:
+ for k in self._invalidatecache:
+ if k == 'dirstate':
+ continue
+ e = self._invalidatecache[k]
+ e[1] = util.stat(e[2])
+
def wlock(self, wait=True):
'''Lock the non-store parts of the repository (everything under
.hg except .hg/store) and return a weak reference to the lock.
diff -r b99305dd5927 -r 87ba99602fd7 mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py Sat Jul 09 19:06:59 2011 +0300
+++ b/mercurial/statichttprepo.py Sat Jul 16 17:34:26 2011 +0300
@@ -125,6 +125,7 @@
self.encodepats = None
self.decodepats = None
self.capabilities.difference_update(["pushkey"])
+ self._invalidatecache = {}
def url(self):
return self._url
More information about the Mercurial-devel
mailing list