Mercurial > hg
changeset 23863:669106fc5bb1
branchcache: make _rbcrevslen handling more safe
self._rbcrevslen is used to keep track of the number of good records on disk.
It should thus not be updated before the records actually have been written to
disk.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 14 Jan 2015 01:15:26 +0100 |
parents | 7aa1405528a3 |
children | 6c44cef5baa2 |
files | mercurial/branchmap.py |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/branchmap.py Wed Jan 14 01:15:26 2015 +0100 +++ b/mercurial/branchmap.py Wed Jan 14 01:15:26 2015 +0100 @@ -431,8 +431,7 @@ start = self._rbcrevslen * _rbcrecsize if start != len(self._rbcrevs): - self._rbcrevslen = min(len(repo.changelog), - len(self._rbcrevs) // _rbcrecsize) + revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize) try: f = repo.vfs.open(_rbcrevs, 'ab') # The position after open(x, 'a') is implementation defined- @@ -442,10 +441,11 @@ repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start)) f.seek(start) f.truncate() - end = self._rbcrevslen * _rbcrecsize + end = revs * _rbcrecsize f.write(self._rbcrevs[start:end]) f.close() except (IOError, OSError, util.Abort), inst: repo.ui.debug("couldn't write revision branch cache: %s\n" % inst) return + self._rbcrevslen = revs