compat: drop getcachevfs, repo.cachevfs is supported in hg 4.4
authorJoerg Sonnenberger <joerg@bec.de>
Sun, 07 Apr 2019 20:00:16 +0200
changeset 4488 6c0992ce05f7
parent 4487 d972041022cb
child 4489 818e8190e867
compat: drop getcachevfs, repo.cachevfs is supported in hg 4.4
hgext3rd/evolve/compat.py
hgext3rd/evolve/depthcache.py
hgext3rd/evolve/firstmergecache.py
hgext3rd/evolve/obscache.py
hgext3rd/evolve/stablesort.py
tests/test-share.t
--- a/hgext3rd/evolve/compat.py	Sun Apr 07 19:53:53 2019 +0200
+++ b/hgext3rd/evolve/compat.py	Sun Apr 07 20:00:16 2019 +0200
@@ -19,7 +19,6 @@
     scmutil,
     util,
     ui as uimod,
-    vfs as vfsmod,
 )
 from mercurial.hgweb import hgweb_mod
 
@@ -100,13 +99,6 @@
                                   copied=copied.get(path))
     return mctx
 
-def getcachevfs(repo):
-    cachevfs = getattr(repo, 'cachevfs', None)
-    if cachevfs is None:
-        cachevfs = vfsmod.vfs(repo.vfs.join('cache'))
-        cachevfs.createmode = repo.store.createmode
-    return cachevfs
-
 def strdiff(a, b, fn1, fn2):
     """ A version of mdiff.unidiff for comparing two strings
     """
--- a/hgext3rd/evolve/depthcache.py	Sun Apr 07 19:53:53 2019 +0200
+++ b/hgext3rd/evolve/depthcache.py	Sun Apr 07 20:00:16 2019 +0200
@@ -178,8 +178,7 @@
         """load data from disk"""
         assert repo.filtername is None
 
-        cachevfs = compat.getcachevfs(repo)
-        data = cachevfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         self._data = array.array('l')
         if not data:
             self._cachekey = self.emptykey
@@ -199,8 +198,7 @@
             return
 
         try:
-            cachevfs = compat.getcachevfs(repo)
-            cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
             headerdata = self._serializecachekey()
             cachefile.write(headerdata)
             cachefile.write(self._data.tostring())
--- a/hgext3rd/evolve/firstmergecache.py	Sun Apr 07 19:53:53 2019 +0200
+++ b/hgext3rd/evolve/firstmergecache.py	Sun Apr 07 20:00:16 2019 +0200
@@ -115,8 +115,7 @@
         """load data from disk"""
         assert repo.filtername is None
 
-        cachevfs = compat.getcachevfs(repo)
-        data = cachevfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         self._data = array.array('l')
         if not data:
             self._cachekey = self.emptykey
@@ -136,8 +135,7 @@
             return
 
         try:
-            cachevfs = compat.getcachevfs(repo)
-            cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
             headerdata = self._serializecachekey()
             cachefile.write(headerdata)
             cachefile.write(self._data.tostring())
--- a/hgext3rd/evolve/obscache.py	Sun Apr 07 19:53:53 2019 +0200
+++ b/hgext3rd/evolve/obscache.py	Sun Apr 07 20:00:16 2019 +0200
@@ -20,7 +20,6 @@
 )
 
 from . import (
-    compat,
     exthelper,
 )
 
@@ -323,7 +322,6 @@
     def __init__(self, repo):
         super(obscache, self).__init__()
         self._ondiskkey = None
-        self._vfs = compat.getcachevfs(repo)
 
     @util.propertycache
     def get(self):
@@ -405,7 +403,7 @@
             return
 
         try:
-            cachefile = self._vfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
             headerdata = struct.pack(self._headerformat, *self._cachekey)
             cachefile.write(headerdata)
             cachefile.write(self._data)
@@ -419,7 +417,7 @@
         """load data from disk"""
         assert repo.filtername is None
 
-        data = self._vfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         if not data:
             self._cachekey = self.emptykey
             self._setdata(bytearray())
--- a/hgext3rd/evolve/stablesort.py	Sun Apr 07 19:53:53 2019 +0200
+++ b/hgext3rd/evolve/stablesort.py	Sun Apr 07 20:00:16 2019 +0200
@@ -608,8 +608,7 @@
         """
         assert repo.filtername is None
 
-        cachevfs = compat.getcachevfs(repo)
-        data = cachevfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         self._index = array.array('l')
         self._data = array.array('l')
         if not data:
@@ -635,8 +634,7 @@
         if self._cachekey is None or self._cachekey == self._ondiskkey:
             return
         try:
-            cachevfs = compat.getcachevfs(repo)
-            cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
 
             # data to write
             headerdata = self._serializecachekey()
--- a/tests/test-share.t	Sun Apr 07 19:53:53 2019 +0200
+++ b/tests/test-share.t	Sun Apr 07 20:00:16 2019 +0200
@@ -1,5 +1,7 @@
 Test that share-clones use the cache in the original repository.
 
+  $ . $TESTDIR/testlib/common.sh
+
   $ hg init share-base
   $ cd share-base/
   $ cat >> .hg/hgrc <<EOF