Patchwork [6,of,8] cachevfs: migration the tags fnode cache to 'cachevfs'

login
register
mail settings
Submitter Boris Feld
Date July 16, 2017, 8:47 a.m.
Message ID <6de7b0ec19f57b99fd48.1500194871@FB>
Download mbox | patch
Permalink /patch/22430/
State Accepted
Headers show

Comments

Boris Feld - July 16, 2017, 8:47 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1500154225 -7200
#      Sat Jul 15 23:30:25 2017 +0200
# Node ID 6de7b0ec19f57b99fd48093a7f5ae41d1d48347c
# Parent  5582979440455dd992f62b43c7a1e8d706750f96
# EXP-Topic cachevfs
cachevfs: migration the tags fnode cache to 'cachevfs'

This will help sharing the cache between shares.

Patch

diff -r 558297944045 -r 6de7b0ec19f5 mercurial/tags.py
--- 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()