##// END OF EJS Templates
localrepo: decorate dirstate() with filecache...
Idan Kamara -
r14930:372d9d8b default
parent child Browse files
Show More
@@ -17,6 +17,7 b' import tags as tagsmod'
17 from lock import release
17 from lock import release
18 import weakref, errno, os, time, inspect
18 import weakref, errno, os, time, inspect
19 propertycache = util.propertycache
19 propertycache = util.propertycache
20 filecache = scmutil.filecache
20
21
21 class localrepository(repo.repository):
22 class localrepository(repo.repository):
22 capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey',
23 capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey',
@@ -187,7 +188,7 b' class localrepository(repo.repository):'
187 def manifest(self):
188 def manifest(self):
188 return manifest.manifest(self.sopener)
189 return manifest.manifest(self.sopener)
189
190
190 @propertycache
191 @filecache('dirstate')
191 def dirstate(self):
192 def dirstate(self):
192 warned = [0]
193 warned = [0]
193 def validate(node):
194 def validate(node):
@@ -797,6 +798,20 b' class localrepository(repo.repository):'
797 self._branchcache = None # in UTF-8
798 self._branchcache = None # in UTF-8
798 self._branchcachetip = None
799 self._branchcachetip = None
799
800
801 def invalidatedirstate(self):
802 '''Invalidates the dirstate, causing the next call to dirstate
803 to check if it was modified since the last time it was read,
804 rereading it if it has.
805
806 This is different to dirstate.invalidate() that it doesn't always
807 rereads the dirstate. Use dirstate.invalidate() if you want to
808 explicitly read the dirstate again (i.e. restoring it to a previous
809 known good state).'''
810 try:
811 delattr(self, 'dirstate')
812 except AttributeError:
813 pass
814
800 def invalidate(self):
815 def invalidate(self):
801 for a in ("changelog", "manifest", "_bookmarks", "_bookmarkcurrent"):
816 for a in ("changelog", "manifest", "_bookmarks", "_bookmarkcurrent"):
802 if a in self.__dict__:
817 if a in self.__dict__:
@@ -841,8 +856,14 b' class localrepository(repo.repository):'
841 l.lock()
856 l.lock()
842 return l
857 return l
843
858
844 l = self._lock(self.join("wlock"), wait, self.dirstate.write,
859 def unlock():
845 self.dirstate.invalidate, _('working directory of %s') %
860 self.dirstate.write()
861 ce = self._filecache.get('dirstate')
862 if ce:
863 ce.refresh()
864
865 l = self._lock(self.join("wlock"), wait, unlock,
866 self.invalidatedirstate, _('working directory of %s') %
846 self.origroot)
867 self.origroot)
847 self._wlockref = weakref.ref(l)
868 self._wlockref = weakref.ref(l)
848 return l
869 return l
General Comments 0
You need to be logged in to leave comments. Login now