diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -1093,12 +1093,13 @@ class _fncachevfs(vfsmod.proxyvfs): ): # do not trigger a fncache load when adding a file that already is # known to exist. - notload = self.fncache.entries is None and self.vfs.exists(encoded) - if notload and b'r+' in mode and not self.vfs.stat(encoded).st_size: - # when appending to an existing file, if the file has size zero, - # it should be considered as missing. Such zero-size files are - # the result of truncation when a transaction is aborted. - notload = False + notload = self.fncache.entries is None and ( + # if the file has size zero, it should be considered as missing. + # Such zero-size files are the result of truncation when a + # transaction is aborted. + self.vfs.exists(encoded) + and self.vfs.stat(encoded).st_size + ) if not notload: self.fncache.add(path) return self.vfs(encoded, mode, *args, **kw) diff --git a/tests/test-transaction-rollback-on-revlog-split.t b/tests/test-transaction-rollback-on-revlog-split.t --- a/tests/test-transaction-rollback-on-revlog-split.t +++ b/tests/test-transaction-rollback-on-revlog-split.t @@ -425,14 +425,6 @@ The split was rollback .hg/store/data/file.d: size=267307 .hg/store/data/file.i: size=320 $ hg verify -q - warning: revlog 'data/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/f.d' not in fncache! - warning: revlog 'data/Directory_With,Special%Char/Complex_File.babar.d' not in fncache! - warning: revlog 'data/file.d' not in fncache! - warning: revlog 'data/foo/bar/babar_celeste/foo.d' not in fncache! - warning: revlog 'data/some_dir/sub_dir/foo_bar.d' not in fncache! - warning: revlog 'data/some_dir/sub_dir/foo_bar.i.s/tutu.d' not in fncache! - 6 warnings encountered! - hint: run "hg debugrebuildfncache" to recover from corrupt fncache $ cd ..