##// END OF EJS Templates
revbranchcache: use context manager in _writerevs() to write to file...
Pulkit Goyal -
r42364:ececa45c default
parent child Browse files
Show More
@@ -652,18 +652,15 b' class revbranchcache(object):'
652
652
653 def _writerevs(self, repo, start):
653 def _writerevs(self, repo, start):
654 """ write the new revs to revbranchcache """
654 """ write the new revs to revbranchcache """
655 revs = min(len(repo.changelog),
655 revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize)
656 len(self._rbcrevs) // _rbcrecsize)
656 with repo.cachevfs.open(_rbcrevs, 'ab') as f:
657 f = repo.cachevfs.open(_rbcrevs, 'ab')
658 if f.tell() != start:
659 repo.ui.debug("truncating cache/%s to %d\n"
660 % (_rbcrevs, start))
661 f.seek(start)
662 if f.tell() != start:
657 if f.tell() != start:
663 start = 0
658 repo.ui.debug("truncating cache/%s to %d\n" % (_rbcrevs, start))
664 f.seek(start)
659 f.seek(start)
665 f.truncate()
660 if f.tell() != start:
666 end = revs * _rbcrecsize
661 start = 0
667 f.write(self._rbcrevs[start:end])
662 f.seek(start)
668 f.close()
663 f.truncate()
664 end = revs * _rbcrecsize
665 f.write(self._rbcrevs[start:end])
669 self._rbcrevslen = revs
666 self._rbcrevslen = revs
General Comments 0
You need to be logged in to leave comments. Login now