##// END OF EJS Templates
store: stop relying on a `revlog_type` property...
marmoute -
r51564:e06d1a77 default
parent child Browse files
Show More
@@ -385,8 +385,8 b' def _calcmode(vfs):'
385 385 b'requires',
386 386 ]
387 387
388 REVLOG_FILES_MAIN_EXT = (b'.i',)
389 REVLOG_FILES_OTHER_EXT = (
388 REVLOG_FILES_EXT = (
389 b'.i',
390 390 b'.idx',
391 391 b'.d',
392 392 b'.dat',
@@ -415,22 +415,16 b" EXCLUDED = re.compile(br'.*undo\\.[^/]+\\."
415 415
416 416 def is_revlog(f, kind, st):
417 417 if kind != stat.S_IFREG:
418 return None
419 return revlog_type(f)
418 return False
419 if f.endswith(REVLOG_FILES_EXT):
420 return True
421 return False
420 422
421 423
422 def revlog_type(f):
423 # XXX we need to filter `undo.` created by the transaction here, however
424 # being naive about it also filter revlog for `undo.*` files, leading to
425 # issue6542. So we no longer use EXCLUDED.
426 if f.endswith(REVLOG_FILES_MAIN_EXT):
427 return FILEFLAGS_REVLOG_MAIN
428 elif f.endswith(REVLOG_FILES_OTHER_EXT):
429 t = FILETYPE_FILELOG_OTHER
430 if f.endswith(REVLOG_FILES_VOLATILE_EXT):
431 t |= FILEFLAGS_VOLATILE
432 return t
433 return None
424 def is_revlog_file(f):
425 if f.endswith(REVLOG_FILES_EXT):
426 return True
427 return False
434 428
435 429
436 430 # the file is part of changelog data
@@ -758,10 +752,9 b' class basicstore:'
758 752 p = visit.pop()
759 753 for f, kind, st in readdir(p, stat=True):
760 754 fp = p + b'/' + f
761 rl_type = is_revlog(f, kind, st)
762 if rl_type is not None:
755 if is_revlog(f, kind, st):
763 756 n = util.pconvert(fp[striplen:])
764 l.append((decodedir(n), (rl_type, st.st_size)))
757 l.append((decodedir(n), st.st_size))
765 758 elif kind == stat.S_IFDIR and recurse:
766 759 visit.append(fp)
767 760
@@ -794,20 +787,16 b' class basicstore:'
794 787 ]
795 788 for base_dir, rl_type, strip_filename in dirs:
796 789 files = self._walk(base_dir, True, undecodable=undecodable)
797 files = (f for f in files if f[1][0] is not None)
798 790 for revlog, details in _gather_revlog(files):
799 file_details = {}
800 791 revlog_target_id = revlog.split(b'/', 1)[1]
801 792 if strip_filename and b'/' in revlog:
802 793 revlog_target_id = revlog_target_id.rsplit(b'/', 1)[0]
803 794 revlog_target_id += b'/'
804 for ext, (t, size) in sorted(details.items()):
805 file_details[ext] = size
806 795 yield RevlogStoreEntry(
807 796 path_prefix=revlog,
808 797 revlog_type=rl_type,
809 798 target_id=revlog_target_id,
810 details=file_details,
799 details=details,
811 800 )
812 801
813 802 def top_entries(
@@ -831,17 +820,17 b' class basicstore:'
831 820 changelogs = collections.defaultdict(dict)
832 821 manifestlogs = collections.defaultdict(dict)
833 822
834 for u, (t, s) in files:
823 for u, s in files:
835 824 if u.startswith(b'00changelog'):
836 825 name, ext = _split_revlog_ext(u)
837 changelogs[name][ext] = (t, s)
826 changelogs[name][ext] = s
838 827 elif u.startswith(b'00manifest'):
839 828 name, ext = _split_revlog_ext(u)
840 manifestlogs[name][ext] = (t, s)
829 manifestlogs[name][ext] = s
841 830 else:
842 831 yield SimpleStoreEntry(
843 832 entry_path=u,
844 is_volatile=bool(t & FILEFLAGS_VOLATILE),
833 is_volatile=False,
845 834 file_size=s,
846 835 )
847 836 # yield manifest before changelog
@@ -853,14 +842,11 b' class basicstore:'
853 842 assert len(changelogs) <= 1
854 843 for data, revlog_type in top_rl:
855 844 for revlog, details in sorted(data.items()):
856 file_details = {}
857 for ext, (t, size) in details.items():
858 file_details[ext] = size
859 845 yield RevlogStoreEntry(
860 846 path_prefix=revlog,
861 847 revlog_type=revlog_type,
862 848 target_id=b'',
863 details=file_details,
849 details=details,
864 850 )
865 851
866 852 def walk(
@@ -1083,7 +1069,7 b' class _fncachevfs(vfsmod.proxyvfs):'
1083 1069 if (
1084 1070 mode not in (b'r', b'rb')
1085 1071 and (path.startswith(b'data/') or path.startswith(b'meta/'))
1086 and revlog_type(path) is not None
1072 and is_revlog_file(path)
1087 1073 ):
1088 1074 # do not trigger a fncache load when adding a file that already is
1089 1075 # known to exist.
@@ -1136,14 +1122,12 b' class fncachestore(basicstore):'
1136 1122 def data_entries(
1137 1123 self, matcher=None, undecodable=None
1138 1124 ) -> Generator[BaseStoreEntry, None, None]:
1139 files = ((f, revlog_type(f)) for f in self.fncache)
1140 1125 # Note: all files in fncache should be revlog related, However the
1141 1126 # fncache might contains such file added by previous version of
1142 1127 # Mercurial.
1143 files = (f for f in files if f[1] is not None)
1128 files = ((f, None) for f in self.fncache if is_revlog_file(f))
1144 1129 by_revlog = _gather_revlog(files)
1145 1130 for revlog, details in by_revlog:
1146 file_details = {}
1147 1131 if revlog.startswith(b'data/'):
1148 1132 rl_type = FILEFLAGS_FILELOG
1149 1133 revlog_target_id = revlog.split(b'/', 1)[1]
@@ -1155,13 +1139,11 b' class fncachestore(basicstore):'
1155 1139 else:
1156 1140 # unreachable
1157 1141 assert False, revlog
1158 for ext in details:
1159 file_details[ext] = None
1160 1142 entry = RevlogStoreEntry(
1161 1143 path_prefix=revlog,
1162 1144 revlog_type=rl_type,
1163 1145 target_id=revlog_target_id,
1164 details=file_details,
1146 details=details,
1165 1147 )
1166 1148 if _match_tracked_entry(entry, matcher):
1167 1149 yield entry
@@ -370,7 +370,7 b' def _files_to_copy_post_revlog_clone(src'
370 370 are cloned"""
371 371 for path, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
372 372 # don't copy revlogs as they are already cloned
373 if store.revlog_type(path) is not None:
373 if store.is_revlog_file(path):
374 374 continue
375 375 # Skip transaction related files.
376 376 if path.startswith(b'undo'):
General Comments 0
You need to be logged in to leave comments. Login now