changeset 33537:709dde1c5dd5

cachevfs: migration the tags fnode cache to 'cachevfs' This will help sharing the cache between shares.
author Boris Feld <boris.feld@octobus.net>
date Sat, 15 Jul 2017 23:30:25 +0200
parents ddacd0e453ae
children 54b36d3ff7f6
files mercurial/tags.py
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/tags.py	Sat Jul 15 23:30:16 2017 +0200
+++ b/mercurial/tags.py	Sat Jul 15 23:30:25 2017 +0200
@@ -617,7 +617,7 @@
 
     return tagnode
 
-_fnodescachefile = 'cache/hgtagsfnodes1'
+_fnodescachefile = 'hgtagsfnodes1'
 _fnodesrecsize = 4 + 20 # changeset fragment + filenode
 _fnodesmissingrec = '\xff' * 24
 
@@ -651,7 +651,7 @@
 
 
         try:
-            data = repo.vfs.read(_fnodescachefile)
+            data = repo.cachevfs.read(_fnodescachefile)
         except (OSError, IOError):
             data = ""
         self._raw = bytearray(data)
@@ -759,13 +759,12 @@
         try:
             lock = repo.wlock(wait=False)
         except error.LockError:
-            repo.ui.log('tagscache',
-                        'not writing .hg/%s because lock cannot be acquired\n' %
-                        (_fnodescachefile))
+            repo.ui.log('tagscache', 'not writing .hg/cache/%s because '
+                        'lock cannot be acquired\n' % (_fnodescachefile))
             return
 
         try:
-            f = repo.vfs.open(_fnodescachefile, 'ab')
+            f = repo.cachevfs.open(_fnodescachefile, 'ab')
             try:
                 # if the file has been truncated
                 actualoffset = f.tell()
@@ -775,7 +774,7 @@
                 f.seek(self._dirtyoffset)
                 f.truncate()
                 repo.ui.log('tagscache',
-                            'writing %d bytes to %s\n' % (
+                            'writing %d bytes to cache/%s\n' % (
                             len(data), _fnodescachefile))
                 f.write(data)
                 self._dirtyoffset = None
@@ -783,7 +782,7 @@
                 f.close()
         except (IOError, OSError) as inst:
             repo.ui.log('tagscache',
-                        "couldn't write %s: %s\n" % (
+                        "couldn't write cache/%s: %s\n" % (
                         _fnodescachefile, inst))
         finally:
             lock.release()