Patchwork [4,of,8] cachevfs: migration the revbranchcache to 'cachevfs'

login
register
mail settings
Submitter Boris Feld
Date July 16, 2017, 8:47 a.m.
Message ID <f15c2ae73d8ee3719ad0.1500194869@FB>
Download mbox | patch
Permalink /patch/22427/
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 1500151370 -7200
#      Sat Jul 15 22:42:50 2017 +0200
# Node ID f15c2ae73d8ee3719ad01c9749da6ece504bc1c4
# Parent  b275e24438be8853ba545a6ee1dd2e5fa1580cd3
# EXP-Topic cachevfs
cachevfs: migration the revbranchcache to 'cachevfs'

This will help sharing the cache between shares.

Patch

diff -r b275e24438be -r f15c2ae73d8e mercurial/branchmap.py
--- a/mercurial/branchmap.py	Sat Jul 15 22:42:31 2017 +0200
+++ b/mercurial/branchmap.py	Sat Jul 15 22:42:50 2017 +0200
@@ -317,8 +317,8 @@ 
 # Revision branch info cache
 
 _rbcversion = '-v1'
-_rbcnames = 'cache/rbc-names' + _rbcversion
-_rbcrevs = 'cache/rbc-revs' + _rbcversion
+_rbcnames = 'rbc-names' + _rbcversion
+_rbcrevs = 'rbc-revs' + _rbcversion
 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open]
 _rbcrecfmt = '>4sI'
 _rbcrecsize = calcsize(_rbcrecfmt)
@@ -356,7 +356,7 @@ 
         self._rbcrevs = bytearray()
         self._rbcsnameslen = 0 # length of names read at _rbcsnameslen
         try:
-            bndata = repo.vfs.read(_rbcnames)
+            bndata = repo.cachevfs.read(_rbcnames)
             self._rbcsnameslen = len(bndata) # for verification before writing
             if bndata:
                 self._names = [encoding.tolocal(bn)
@@ -368,7 +368,7 @@ 
 
         if self._names:
             try:
-                data = repo.vfs.read(_rbcrevs)
+                data = repo.cachevfs.read(_rbcrevs)
                 self._rbcrevs[:] = data
             except (IOError, OSError) as inst:
                 repo.ui.debug("couldn't read revision branch cache: %s\n" %
@@ -473,7 +473,7 @@ 
                 step = ' names'
                 wlock = repo.wlock(wait=False)
                 if self._rbcnamescount != 0:
-                    f = repo.vfs.open(_rbcnames, 'ab')
+                    f = repo.cachevfs.open(_rbcnames, 'ab')
                     if f.tell() == self._rbcsnameslen:
                         f.write('\0')
                     else:
@@ -483,8 +483,8 @@ 
                         self._rbcrevslen = 0
                 if self._rbcnamescount == 0:
                     # before rewriting names, make sure references are removed
-                    repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True)
-                    f = repo.vfs.open(_rbcnames, 'wb')
+                    repo.cachevfs.unlinkpath(_rbcrevs, ignoremissing=True)
+                    f = repo.cachevfs.open(_rbcnames, 'wb')
                 f.write('\0'.join(encoding.fromlocal(b)
                                   for b in self._names[self._rbcnamescount:]))
                 self._rbcsnameslen = f.tell()
@@ -498,9 +498,10 @@ 
                     wlock = repo.wlock(wait=False)
                 revs = min(len(repo.changelog),
                            len(self._rbcrevs) // _rbcrecsize)
-                f = repo.vfs.open(_rbcrevs, 'ab')
+                f = repo.cachevfs.open(_rbcrevs, 'ab')
                 if f.tell() != start:
-                    repo.ui.debug("truncating %s to %d\n" % (_rbcrevs, start))
+                    repo.ui.debug("truncating cache/%s to %d\n"
+                                  % (_rbcrevs, start))
                     f.seek(start)
                     if f.tell() != start:
                         start = 0