changeset 33535:755e6532e81d

cachevfs: migration the revbranchcache to 'cachevfs' This will help sharing the cache between shares.
author Boris Feld <boris.feld@octobus.net>
date Sat, 15 Jul 2017 22:42:50 +0200
parents 2715a4fc0684
children ddacd0e453ae
files mercurial/branchmap.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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