##// END OF EJS Templates
store: also gather files per revlog in `topfiles`...
marmoute -
r51374:b08243db default
parent child Browse files
Show More
@@ -563,6 +563,23 b' def _split_revlog_ext(filename):'
563 return filename[:idx], filename[idx:]
563 return filename[:idx], filename[idx:]
564
564
565
565
566 def _ext_key(ext):
567 """a key to order revlog suffix
568
569 important to issue .i after other entry."""
570 # the only important part of this order is to keep the `.i` last.
571 if ext.endswith(b'.n'):
572 return (0, ext)
573 elif ext.endswith(b'.nd'):
574 return (10, ext)
575 elif ext.endswith(b'.d'):
576 return (20, ext)
577 elif ext.endswith(b'.i'):
578 return (50, ext)
579 else:
580 return (40, ext)
581
582
566 class basicstore:
583 class basicstore:
567 '''base class for local repository stores'''
584 '''base class for local repository stores'''
568
585
@@ -636,34 +653,44 b' class basicstore:'
636 )
653 )
637
654
638 def topfiles(self) -> Generator[BaseStoreEntry, None, None]:
655 def topfiles(self) -> Generator[BaseStoreEntry, None, None]:
639 # yield manifest before changelog
656 files = reversed(self._walk(b'', False))
640 files = self._walk(b'', False)
657
641 # key is (type, path) (keeping ordering so we get 00changelog.i last)
658 changelogs = collections.defaultdict(dict)
642 type_key = lambda x: (x[1][0], x[0])
659 manifestlogs = collections.defaultdict(dict)
643 files = sorted(files, reverse=True, key=type_key)
660
644 for u, (t, s) in files:
661 for u, (t, s) in files:
645 if u.startswith(b'00changelog'):
662 if u.startswith(b'00changelog'):
646 yield RevlogStoreEntry(
663 name, ext = _split_revlog_ext(u)
647 unencoded_path=u,
664 changelogs[name][ext] = (t, s)
648 revlog_type=FILEFLAGS_CHANGELOG,
649 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
650 is_volatile=bool(t & FILEFLAGS_VOLATILE),
651 file_size=s,
652 )
653 elif u.startswith(b'00manifest'):
665 elif u.startswith(b'00manifest'):
654 yield RevlogStoreEntry(
666 name, ext = _split_revlog_ext(u)
655 unencoded_path=u,
667 manifestlogs[name][ext] = (t, s)
656 revlog_type=FILEFLAGS_MANIFESTLOG,
657 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
658 is_volatile=bool(t & FILEFLAGS_VOLATILE),
659 file_size=s,
660 )
661 else:
668 else:
662 yield SimpleStoreEntry(
669 yield SimpleStoreEntry(
663 unencoded_path=u,
670 unencoded_path=u,
664 is_volatile=bool(t & FILEFLAGS_VOLATILE),
671 is_volatile=bool(t & FILEFLAGS_VOLATILE),
665 file_size=s,
672 file_size=s,
666 )
673 )
674 # yield manifest before changelog
675 top_rl = [
676 (manifestlogs, FILEFLAGS_MANIFESTLOG),
677 (changelogs, FILEFLAGS_CHANGELOG),
678 ]
679 assert len(manifestlogs) <= 1
680 assert len(changelogs) <= 1
681 for data, revlog_type in top_rl:
682 for revlog, details in sorted(data.items()):
683 # (keeping ordering so we get 00changelog.i last)
684 key = lambda x: _ext_key(x[0])
685 for ext, (t, s) in sorted(details.items(), key=key):
686 u = revlog + ext
687 yield RevlogStoreEntry(
688 unencoded_path=u,
689 revlog_type=revlog_type,
690 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
691 is_volatile=bool(t & FILEFLAGS_VOLATILE),
692 file_size=s,
693 )
667
694
668 def walk(self, matcher=None) -> Generator[BaseStoreEntry, None, None]:
695 def walk(self, matcher=None) -> Generator[BaseStoreEntry, None, None]:
669 """return files related to data storage (ie: revlogs)
696 """return files related to data storage (ie: revlogs)
@@ -1018,14 +1018,14 b' No race condition'
1018 $ hg clone -U --stream ssh://user@dummy/test-repo stream-clone --debug | egrep '00(changelog|manifest)'
1018 $ hg clone -U --stream ssh://user@dummy/test-repo stream-clone --debug | egrep '00(changelog|manifest)'
1019 adding [s] 00manifest.n (62 bytes)
1019 adding [s] 00manifest.n (62 bytes)
1020 adding [s] 00manifest-*.nd (118 KB) (glob)
1020 adding [s] 00manifest-*.nd (118 KB) (glob)
1021 adding [s] 00manifest.d (491 KB) (zstd no-bigendian !)
1022 adding [s] 00manifest.d (452 KB) (no-zstd !)
1023 adding [s] 00manifest.d (492 KB) (zstd bigendian !)
1024 adding [s] 00manifest.i (313 KB)
1021 adding [s] 00changelog.n (62 bytes)
1025 adding [s] 00changelog.n (62 bytes)
1022 adding [s] 00changelog-*.nd (118 KB) (glob)
1026 adding [s] 00changelog-*.nd (118 KB) (glob)
1023 adding [s] 00manifest.d (452 KB) (no-zstd !)
1024 adding [s] 00manifest.d (491 KB) (zstd no-bigendian !)
1025 adding [s] 00manifest.d (492 KB) (zstd bigendian !)
1026 adding [s] 00changelog.d (360 KB) (no-zstd !)
1027 adding [s] 00changelog.d (360 KB) (no-zstd !)
1027 adding [s] 00changelog.d (368 KB) (zstd !)
1028 adding [s] 00changelog.d (368 KB) (zstd !)
1028 adding [s] 00manifest.i (313 KB)
1029 adding [s] 00changelog.i (313 KB)
1029 adding [s] 00changelog.i (313 KB)
1030 $ ls -1 stream-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
1030 $ ls -1 stream-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
1031 00changelog-*.nd (glob)
1031 00changelog-*.nd (glob)
@@ -1090,14 +1090,14 b' Do a mix of clone and commit at the same'
1090 $ cat clone-output
1090 $ cat clone-output
1091 adding [s] 00manifest.n (62 bytes)
1091 adding [s] 00manifest.n (62 bytes)
1092 adding [s] 00manifest-*.nd (118 KB) (glob)
1092 adding [s] 00manifest-*.nd (118 KB) (glob)
1093 adding [s] 00manifest.d (491 KB) (zstd no-bigendian !)
1094 adding [s] 00manifest.d (452 KB) (no-zstd !)
1095 adding [s] 00manifest.d (492 KB) (zstd bigendian !)
1096 adding [s] 00manifest.i (313 KB)
1093 adding [s] 00changelog.n (62 bytes)
1097 adding [s] 00changelog.n (62 bytes)
1094 adding [s] 00changelog-*.nd (118 KB) (glob)
1098 adding [s] 00changelog-*.nd (118 KB) (glob)
1095 adding [s] 00manifest.d (452 KB) (no-zstd !)
1099 adding [s] 00changelog.d (368 KB) (zstd !)
1096 adding [s] 00manifest.d (491 KB) (zstd no-bigendian !)
1097 adding [s] 00manifest.d (492 KB) (zstd bigendian !)
1098 adding [s] 00changelog.d (360 KB) (no-zstd !)
1100 adding [s] 00changelog.d (360 KB) (no-zstd !)
1099 adding [s] 00changelog.d (368 KB) (zstd !)
1100 adding [s] 00manifest.i (313 KB)
1101 adding [s] 00changelog.i (313 KB)
1101 adding [s] 00changelog.i (313 KB)
1102
1102
1103 Check the result state
1103 Check the result state
@@ -1195,13 +1195,13 b' Performe the mix of clone and full refre'
1195 $ cat clone-output-2
1195 $ cat clone-output-2
1196 adding [s] 00manifest.n (62 bytes)
1196 adding [s] 00manifest.n (62 bytes)
1197 adding [s] 00manifest-*.nd (118 KB) (glob)
1197 adding [s] 00manifest-*.nd (118 KB) (glob)
1198 adding [s] 00changelog.n (62 bytes)
1199 adding [s] 00changelog-*.nd (118 KB) (glob)
1200 adding [s] 00manifest.d (492 KB) (zstd !)
1198 adding [s] 00manifest.d (492 KB) (zstd !)
1201 adding [s] 00manifest.d (452 KB) (no-zstd !)
1199 adding [s] 00manifest.d (452 KB) (no-zstd !)
1200 adding [s] 00manifest.i (313 KB)
1201 adding [s] 00changelog.n (62 bytes)
1202 adding [s] 00changelog-*.nd (118 KB) (glob)
1202 adding [s] 00changelog.d (360 KB) (no-zstd !)
1203 adding [s] 00changelog.d (360 KB) (no-zstd !)
1203 adding [s] 00changelog.d (368 KB) (zstd !)
1204 adding [s] 00changelog.d (368 KB) (zstd !)
1204 adding [s] 00manifest.i (313 KB)
1205 adding [s] 00changelog.i (313 KB)
1205 adding [s] 00changelog.i (313 KB)
1206
1206
1207 Check the result.
1207 Check the result.
General Comments 0
You need to be logged in to leave comments. Login now