diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -520,9 +520,17 @@ class StoreFile: """a file matching an entry""" unencoded_path = attr.ib() - file_size = attr.ib() + _file_size = attr.ib(default=False) is_volatile = attr.ib(default=False) + def file_size(self, vfs): + if self._file_size is not None: + return self._file_size + try: + return vfs.stat(self.unencoded_path).st_size + except FileNotFoundError: + return 0 + class basicstore: '''base class for local repository stores''' @@ -900,16 +908,12 @@ class fncachestore(basicstore): # However the fncache might contains such file added by # previous version of Mercurial. continue - try: - yield RevlogStoreEntry( - unencoded_path=f, - revlog_type=FILEFLAGS_FILELOG, - is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), - is_volatile=bool(t & FILEFLAGS_VOLATILE), - file_size=self.getsize(ef), - ) - except FileNotFoundError: - pass + yield RevlogStoreEntry( + unencoded_path=f, + revlog_type=FILEFLAGS_FILELOG, + is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), + is_volatile=bool(t & FILEFLAGS_VOLATILE), + ) def copylist(self): d = ( diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -271,9 +271,10 @@ def generatev1(repo): repo.ui.debug(b'scanning\n') for entry in _walkstreamfiles(repo): for f in entry.files(): - if f.file_size: - entries.append((f.unencoded_path, f.file_size)) - total_bytes += f.file_size + file_size = f.file_size(repo.store.vfs) + if file_size: + entries.append((f.unencoded_path, file_size)) + total_bytes += file_size _test_sync_point_walk_1(repo) _test_sync_point_walk_2(repo) @@ -680,12 +681,13 @@ def _v2_walk(repo, includes, excludes, i for entry in _walkstreamfiles(repo, matcher): for f in entry.files(): - if f.file_size: + file_size = f.file_size(repo.store.vfs) + if file_size: ft = _fileappend if f.is_volatile: ft = _filefull - entries.append((_srcstore, f.unencoded_path, ft, f.file_size)) - totalfilesize += f.file_size + entries.append((_srcstore, f.unencoded_path, ft, file_size)) + totalfilesize += file_size for name in _walkstreamfullstorefiles(repo): if repo.svfs.exists(name): totalfilesize += repo.svfs.lstat(name).st_size diff --git a/mercurial/verify.py b/mercurial/verify.py --- a/mercurial/verify.py +++ b/mercurial/verify.py @@ -410,7 +410,7 @@ class verifier: for entry in repo.store.datafiles(undecodable=undecodable): for file_ in entry.files(): f = file_.unencoded_path - size = file_.file_size + size = file_.file_size(repo.store.vfs) if (size > 0 or not revlogv1) and f.startswith(b'meta/'): storefiles.add(_normpath(f)) subdirs.add(os.path.dirname(f)) @@ -477,7 +477,7 @@ class verifier: undecodable = [] for entry in repo.store.datafiles(undecodable=undecodable): for file_ in entry.files(): - size = file_.file_size + size = file_.file_size(repo.store.vfs) f = file_.unencoded_path if (size > 0 or not revlogv1) and f.startswith(b'data/'): storefiles.add(_normpath(f))