Mercurial > hg
comparison mercurial/branchmap.py @ 28557:4b83507bfc91
cache: safer handling of failing seek when writing revision branch cache
If the seek for some reason fails (perhaps because the file is too short to
search to the requested position), make sure we seek to the start and rewrite
everything.
It is unknown if this fixes a real problem that ever happened.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Sun, 13 Mar 2016 02:06:22 +0100 |
parents | 0706d60d070f |
children | bcd106d456c4 |
comparison
equal
deleted
inserted
replaced
28556:0706d60d070f | 28557:4b83507bfc91 |
---|---|
480 try: | 480 try: |
481 f = repo.vfs.open(_rbcrevs, 'ab') | 481 f = repo.vfs.open(_rbcrevs, 'ab') |
482 if f.tell() != start: | 482 if f.tell() != start: |
483 repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start)) | 483 repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start)) |
484 f.seek(start) | 484 f.seek(start) |
485 if f.tell() != start: | |
486 start = 0 | |
487 f.seek(start) | |
485 f.truncate() | 488 f.truncate() |
486 end = revs * _rbcrecsize | 489 end = revs * _rbcrecsize |
487 f.write(self._rbcrevs[start:end]) | 490 f.write(self._rbcrevs[start:end]) |
488 f.close() | 491 f.close() |
489 except (IOError, OSError, error.Abort) as inst: | 492 except (IOError, OSError, error.Abort) as inst: |