# HG changeset patch # User Mads Kiilerich # Date 1457831182 -3600 # Node ID 4b83507bfc919acc2f3ec2ced0e1e94e05be6371 # Parent 0706d60d070f7e1c545c08c1ba774de1e7a792b9 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. diff -r 0706d60d070f -r 4b83507bfc91 mercurial/branchmap.py --- a/mercurial/branchmap.py Sun Mar 13 02:06:21 2016 +0100 +++ b/mercurial/branchmap.py Sun Mar 13 02:06:22 2016 +0100 @@ -482,6 +482,9 @@ if f.tell() != start: repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start)) f.seek(start) + if f.tell() != start: + start = 0 + f.seek(start) f.truncate() end = revs * _rbcrecsize f.write(self._rbcrevs[start:end])