##// END OF EJS Templates
cachevfs: migration the revbranchcache to 'cachevfs'...
Boris Feld -
r33535:755e6532 default
parent child Browse files
Show More
@@ -317,8 +317,8 b' class branchcache(dict):'
317 # Revision branch info cache
317 # Revision branch info cache
318
318
319 _rbcversion = '-v1'
319 _rbcversion = '-v1'
320 _rbcnames = 'cache/rbc-names' + _rbcversion
320 _rbcnames = 'rbc-names' + _rbcversion
321 _rbcrevs = 'cache/rbc-revs' + _rbcversion
321 _rbcrevs = 'rbc-revs' + _rbcversion
322 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open]
322 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open]
323 _rbcrecfmt = '>4sI'
323 _rbcrecfmt = '>4sI'
324 _rbcrecsize = calcsize(_rbcrecfmt)
324 _rbcrecsize = calcsize(_rbcrecfmt)
@@ -356,7 +356,7 b' class revbranchcache(object):'
356 self._rbcrevs = bytearray()
356 self._rbcrevs = bytearray()
357 self._rbcsnameslen = 0 # length of names read at _rbcsnameslen
357 self._rbcsnameslen = 0 # length of names read at _rbcsnameslen
358 try:
358 try:
359 bndata = repo.vfs.read(_rbcnames)
359 bndata = repo.cachevfs.read(_rbcnames)
360 self._rbcsnameslen = len(bndata) # for verification before writing
360 self._rbcsnameslen = len(bndata) # for verification before writing
361 if bndata:
361 if bndata:
362 self._names = [encoding.tolocal(bn)
362 self._names = [encoding.tolocal(bn)
@@ -368,7 +368,7 b' class revbranchcache(object):'
368
368
369 if self._names:
369 if self._names:
370 try:
370 try:
371 data = repo.vfs.read(_rbcrevs)
371 data = repo.cachevfs.read(_rbcrevs)
372 self._rbcrevs[:] = data
372 self._rbcrevs[:] = data
373 except (IOError, OSError) as inst:
373 except (IOError, OSError) as inst:
374 repo.ui.debug("couldn't read revision branch cache: %s\n" %
374 repo.ui.debug("couldn't read revision branch cache: %s\n" %
@@ -473,7 +473,7 b' class revbranchcache(object):'
473 step = ' names'
473 step = ' names'
474 wlock = repo.wlock(wait=False)
474 wlock = repo.wlock(wait=False)
475 if self._rbcnamescount != 0:
475 if self._rbcnamescount != 0:
476 f = repo.vfs.open(_rbcnames, 'ab')
476 f = repo.cachevfs.open(_rbcnames, 'ab')
477 if f.tell() == self._rbcsnameslen:
477 if f.tell() == self._rbcsnameslen:
478 f.write('\0')
478 f.write('\0')
479 else:
479 else:
@@ -483,8 +483,8 b' class revbranchcache(object):'
483 self._rbcrevslen = 0
483 self._rbcrevslen = 0
484 if self._rbcnamescount == 0:
484 if self._rbcnamescount == 0:
485 # before rewriting names, make sure references are removed
485 # before rewriting names, make sure references are removed
486 repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True)
486 repo.cachevfs.unlinkpath(_rbcrevs, ignoremissing=True)
487 f = repo.vfs.open(_rbcnames, 'wb')
487 f = repo.cachevfs.open(_rbcnames, 'wb')
488 f.write('\0'.join(encoding.fromlocal(b)
488 f.write('\0'.join(encoding.fromlocal(b)
489 for b in self._names[self._rbcnamescount:]))
489 for b in self._names[self._rbcnamescount:]))
490 self._rbcsnameslen = f.tell()
490 self._rbcsnameslen = f.tell()
@@ -498,9 +498,10 b' class revbranchcache(object):'
498 wlock = repo.wlock(wait=False)
498 wlock = repo.wlock(wait=False)
499 revs = min(len(repo.changelog),
499 revs = min(len(repo.changelog),
500 len(self._rbcrevs) // _rbcrecsize)
500 len(self._rbcrevs) // _rbcrecsize)
501 f = repo.vfs.open(_rbcrevs, 'ab')
501 f = repo.cachevfs.open(_rbcrevs, 'ab')
502 if f.tell() != start:
502 if f.tell() != start:
503 repo.ui.debug("truncating %s to %d\n" % (_rbcrevs, start))
503 repo.ui.debug("truncating cache/%s to %d\n"
504 % (_rbcrevs, start))
504 f.seek(start)
505 f.seek(start)
505 if f.tell() != start:
506 if f.tell() != start:
506 start = 0
507 start = 0
General Comments 0
You need to be logged in to leave comments. Login now