compat: in depth cache, only use cachevfs when available
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 29 Nov 2017 12:48:45 -0500
changeset 3242 55e1ad0d7174
parent 3241 0d2c095aeb2a
child 3243 556316fe4b4f
compat: in depth cache, only use cachevfs when available We support older version without the new vfs.
hgext3rd/evolve/depthcache.py
--- a/hgext3rd/evolve/depthcache.py	Thu Nov 23 16:53:29 2017 +0100
+++ b/hgext3rd/evolve/depthcache.py	Wed Nov 29 12:48:45 2017 -0500
@@ -196,7 +196,10 @@
         """load data from disk"""
         assert repo.filtername is None
 
-        data = repo.cachevfs.tryread(self._filepath)
+        if util.safehasattr(repo, 'cachevfs'):
+            data = repo.cachevfs.tryread(self._filepath)
+        else:
+            data = repo.vfs.tryread('cache/' + self._filepath)
         self._data = array.array('l')
         if not data:
             self._cachekey = self.emptykey
@@ -215,7 +218,10 @@
         if self._cachekey is None or self._cachekey == self._ondiskkey:
             return
 
-        cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
+        if util.safehasattr(repo, 'cachevfs'):
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
+        else:
+            cachefile = repo.vfs('cache/' + self._filepath, 'w', atomictemp=True)
         headerdata = self._serializecachekey()
         cachefile.write(headerdata)
         cachefile.write(self._data.tostring())