Mercurial > public > mercurial-scm > hg
diff mercurial/branching/rev_cache.py @ 51898:1eb2317c1762
rev-branch-cache: issue more truthful "truncating" message
First, don't pretend it truncate to 40 when it actually truncate to 0. Second,
don't pretend to truncate to 0 when the file is already empty/missing.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 24 Sep 2024 00:01:30 +0200 |
parents | f0e07efc199f |
children | 9f7cf869e9f4 |
line wrap: on
line diff
--- a/mercurial/branching/rev_cache.py Sun Sep 22 15:55:46 2024 +0200 +++ b/mercurial/branching/rev_cache.py Tue Sep 24 00:01:30 2024 +0200 @@ -336,14 +336,14 @@ """write the new revs to revbranchcache""" revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize) with repo.cachevfs.open(_rbcrevs, b'ab') as f: - if f.tell() != start: - repo.ui.debug( - b"truncating cache/%s to %d\n" % (_rbcrevs, start) - ) + current_size = f.tell() + if current_size < start: + start = 0 + if current_size != start: + msg = b"truncating cache/%s to %d\n" + msg %= (_rbcrevs, start) + repo.ui.debug(msg) f.seek(start) - if f.tell() != start: - start = 0 - f.seek(start) f.truncate() end = revs * _rbcrecsize f.write(self._rbcrevs.slice(start, end))