cache: safer handling of failing seek when writing revision branch cache
authorMads Kiilerich <madski@unity3d.com>
Sun, 13 Mar 2016 02:06:22 +0100
changeset 28557 4b83507bfc91
parent 28556 0706d60d070f
child 28558 bcd106d456c4
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.
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])