# HG changeset patch # User Mads Kiilerich # Date 2016-03-13 01:06:22 # 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 --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -482,6 +482,9 @@ class revbranchcache(object): 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])