# HG changeset patch # User Boris Feld # Date 2017-07-15 20:42:50 # Node ID 755e6532e81d2352cdefc3d3037a1b9f0d3ed52e # Parent 2715a4fc0684a90791a9c4fab89884a2456f04ba cachevfs: migration the revbranchcache to 'cachevfs' This will help sharing the cache between shares. diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -317,8 +317,8 @@ class branchcache(dict): # 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 @@ class revbranchcache(object): 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 @@ class revbranchcache(object): 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 @@ class revbranchcache(object): 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 @@ class revbranchcache(object): 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 @@ class revbranchcache(object): 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