comparison mercurial/branchmap.py @ 23862:7aa1405528a3

branchcache: add debug output whenever cache files use truncate The cache files are usually append only but will automatically be truncated and recover in exceptional situations. Add a debug notice when such exceptional situations are encountered.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 14 Jan 2015 01:15:26 +0100
parents 6bf93440a717
children 669106fc5bb1
comparison
equal deleted inserted replaced
23861:01426cad66dc 23862:7aa1405528a3
412 f.seek(0, 2) #os.SEEK_END 412 f.seek(0, 2) #os.SEEK_END
413 if f.tell() == self._rbcsnameslen: 413 if f.tell() == self._rbcsnameslen:
414 f.write('\0') 414 f.write('\0')
415 else: 415 else:
416 f.close() 416 f.close()
417 repo.ui.debug("%s changed - rewriting it\n" % _rbcnames)
417 self._rbcnamescount = 0 418 self._rbcnamescount = 0
418 self._rbcrevslen = 0 419 self._rbcrevslen = 0
419 if self._rbcnamescount == 0: 420 if self._rbcnamescount == 0:
420 f = repo.vfs.open(_rbcnames, 'wb') 421 f = repo.vfs.open(_rbcnames, 'wb')
421 f.write('\0'.join(encoding.fromlocal(b) 422 f.write('\0'.join(encoding.fromlocal(b)
436 f = repo.vfs.open(_rbcrevs, 'ab') 437 f = repo.vfs.open(_rbcrevs, 'ab')
437 # The position after open(x, 'a') is implementation defined- 438 # The position after open(x, 'a') is implementation defined-
438 # see issue3543. SEEK_END was added in 2.5 439 # see issue3543. SEEK_END was added in 2.5
439 f.seek(0, 2) #os.SEEK_END 440 f.seek(0, 2) #os.SEEK_END
440 if f.tell() != start: 441 if f.tell() != start:
442 repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start))
441 f.seek(start) 443 f.seek(start)
442 f.truncate() 444 f.truncate()
443 end = self._rbcrevslen * _rbcrecsize 445 end = self._rbcrevslen * _rbcrecsize
444 f.write(self._rbcrevs[start:end]) 446 f.write(self._rbcrevs[start:end])
445 f.close() 447 f.close()