diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -7,6 +7,7 @@ from __future__ import absolute_import +import io import struct from .node import ( @@ -640,6 +641,7 @@ """ write the new branch names to revbranchcache """ if self._rbcnamescount != 0: f = repo.cachevfs.open(_rbcnames, 'ab') + f.seek(0, io.SEEK_END) if f.tell() == self._rbcsnameslen: f.write('\0') else: @@ -661,6 +663,7 @@ """ write the new revs to revbranchcache """ revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize) with repo.cachevfs.open(_rbcrevs, 'ab') as f: + f.seek(0, io.SEEK_END) if f.tell() != start: repo.ui.debug("truncating cache/%s to %d\n" % (_rbcrevs, start)) f.seek(start) diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -71,6 +71,7 @@ import errno import hashlib +import io import struct from .i18n import _ @@ -625,6 +626,7 @@ new.append(m) if new: f = self.svfs('obsstore', 'ab') + f.seek(0, io.SEEK_END) try: offset = f.tell() transaction.add('obsstore', offset) diff --git a/mercurial/tags.py b/mercurial/tags.py --- a/mercurial/tags.py +++ b/mercurial/tags.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import errno +import io from .node import ( bin, @@ -584,6 +585,7 @@ fp = repo.vfs('localtags', 'r+') except IOError: fp = repo.vfs('localtags', 'a') + fp.seek(0, io.SEEK_END) else: prevtags = fp.read() @@ -599,6 +601,7 @@ if e.errno != errno.ENOENT: raise fp = repo.wvfs('.hgtags', 'ab') + fp.seek(0, io.SEEK_END) else: prevtags = fp.read() @@ -793,6 +796,7 @@ try: f = repo.cachevfs.open(_fnodescachefile, 'ab') + f.seek(0, io.SEEK_END) try: # if the file has been truncated actualoffset = f.tell()