##// END OF EJS Templates
store: lazily get file size on demand for the fncache case...
marmoute -
r51370:4cbdfab6 default
parent child Browse files
Show More
@@ -520,9 +520,17 b' class StoreFile:'
520 520 """a file matching an entry"""
521 521
522 522 unencoded_path = attr.ib()
523 file_size = attr.ib()
523 _file_size = attr.ib(default=False)
524 524 is_volatile = attr.ib(default=False)
525 525
526 def file_size(self, vfs):
527 if self._file_size is not None:
528 return self._file_size
529 try:
530 return vfs.stat(self.unencoded_path).st_size
531 except FileNotFoundError:
532 return 0
533
526 534
527 535 class basicstore:
528 536 '''base class for local repository stores'''
@@ -900,16 +908,12 b' class fncachestore(basicstore):'
900 908 # However the fncache might contains such file added by
901 909 # previous version of Mercurial.
902 910 continue
903 try:
904 yield RevlogStoreEntry(
905 unencoded_path=f,
906 revlog_type=FILEFLAGS_FILELOG,
907 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
908 is_volatile=bool(t & FILEFLAGS_VOLATILE),
909 file_size=self.getsize(ef),
910 )
911 except FileNotFoundError:
912 pass
911 yield RevlogStoreEntry(
912 unencoded_path=f,
913 revlog_type=FILEFLAGS_FILELOG,
914 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
915 is_volatile=bool(t & FILEFLAGS_VOLATILE),
916 )
913 917
914 918 def copylist(self):
915 919 d = (
@@ -271,9 +271,10 b' def generatev1(repo):'
271 271 repo.ui.debug(b'scanning\n')
272 272 for entry in _walkstreamfiles(repo):
273 273 for f in entry.files():
274 if f.file_size:
275 entries.append((f.unencoded_path, f.file_size))
276 total_bytes += f.file_size
274 file_size = f.file_size(repo.store.vfs)
275 if file_size:
276 entries.append((f.unencoded_path, file_size))
277 total_bytes += file_size
277 278 _test_sync_point_walk_1(repo)
278 279 _test_sync_point_walk_2(repo)
279 280
@@ -680,12 +681,13 b' def _v2_walk(repo, includes, excludes, i'
680 681
681 682 for entry in _walkstreamfiles(repo, matcher):
682 683 for f in entry.files():
683 if f.file_size:
684 file_size = f.file_size(repo.store.vfs)
685 if file_size:
684 686 ft = _fileappend
685 687 if f.is_volatile:
686 688 ft = _filefull
687 entries.append((_srcstore, f.unencoded_path, ft, f.file_size))
688 totalfilesize += f.file_size
689 entries.append((_srcstore, f.unencoded_path, ft, file_size))
690 totalfilesize += file_size
689 691 for name in _walkstreamfullstorefiles(repo):
690 692 if repo.svfs.exists(name):
691 693 totalfilesize += repo.svfs.lstat(name).st_size
@@ -410,7 +410,7 b' class verifier:'
410 410 for entry in repo.store.datafiles(undecodable=undecodable):
411 411 for file_ in entry.files():
412 412 f = file_.unencoded_path
413 size = file_.file_size
413 size = file_.file_size(repo.store.vfs)
414 414 if (size > 0 or not revlogv1) and f.startswith(b'meta/'):
415 415 storefiles.add(_normpath(f))
416 416 subdirs.add(os.path.dirname(f))
@@ -477,7 +477,7 b' class verifier:'
477 477 undecodable = []
478 478 for entry in repo.store.datafiles(undecodable=undecodable):
479 479 for file_ in entry.files():
480 size = file_.file_size
480 size = file_.file_size(repo.store.vfs)
481 481 f = file_.unencoded_path
482 482 if (size > 0 or not revlogv1) and f.startswith(b'data/'):
483 483 storefiles.add(_normpath(f))
General Comments 0
You need to be logged in to leave comments. Login now