mercurial/branchmap.py
changeset 42185 ececa45c80d8
parent 42184 09fd338522fa
child 42190 7c0ece3cd3ee
equal deleted inserted replaced
42184:09fd338522fa 42185:ececa45c80d8
   650         f.close()
   650         f.close()
   651         self._rbcnamescount = len(self._names)
   651         self._rbcnamescount = len(self._names)
   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