##// END OF EJS Templates
debug: add debug-revlog-stats command...
Franck Bret -
r50714:b1e4c74b default
parent child Browse files
Show More
@@ -0,0 +1,77 b''
1 Force revlog max inline value to be smaller than default
2
3 $ mkdir $TESTTMP/ext
4 $ cat << EOF > $TESTTMP/ext/small_inline.py
5 > from mercurial import revlog
6 > revlog._maxinline = 8
7 > EOF
8
9 $ cat << EOF >> $HGRCPATH
10 > [extensions]
11 > small_inline=$TESTTMP/ext/small_inline.py
12 > EOF
13
14 $ hg init repo
15 $ cd repo
16
17 Try on an empty repository
18
19 $ hg debug-revlog-stats
20 rev-count data-size inl type target
21 0 0 yes changelog
22 0 0 yes manifest
23
24 $ mkdir folder
25 $ touch a b folder/c folder/d
26 $ hg commit -Aqm 0
27 $ echo "text" > a
28 $ hg rm b
29 $ echo "longer string" > folder/d
30 $ hg commit -Aqm 1
31
32 Differences in data size observed with pure is due to different compression
33 algorithms
34
35 $ hg debug-revlog-stats
36 rev-count data-size inl type target
37 2 138 no changelog (no-pure !)
38 2 137 no changelog (pure !)
39 2 177 no manifest (no-pure !)
40 2 168 no manifest (pure !)
41 2 6 yes file a
42 1 0 yes file b
43 1 0 yes file folder/c
44 2 15 no file folder/d
45
46 Test 'changelog' command argument
47
48 $ hg debug-revlog-stats -c
49 rev-count data-size inl type target
50 2 138 no changelog (no-pure !)
51 2 137 no changelog (pure !)
52
53 Test 'manifest' command argument
54
55 $ hg debug-revlog-stats -m
56 rev-count data-size inl type target
57 2 177 no manifest (no-pure !)
58 2 168 no manifest (pure !)
59
60 Test 'file' command argument
61
62 $ hg debug-revlog-stats -f
63 rev-count data-size inl type target
64 2 6 yes file a
65 1 0 yes file b
66 1 0 yes file folder/c
67 2 15 no file folder/d
68
69 Test multiple command arguments
70
71 $ hg debug-revlog-stats -cm
72 rev-count data-size inl type target
73 2 138 no changelog (no-pure !)
74 2 137 no changelog (pure !)
75 2 177 no manifest (no-pure !)
76 2 168 no manifest (pure !)
77
@@ -3809,6 +3809,33 b' def debugshell(ui, repo):'
3809
3809
3810
3810
3811 @command(
3811 @command(
3812 b'debug-revlog-stats',
3813 [
3814 (b'c', b'changelog', None, _(b'Display changelog statistics')),
3815 (b'm', b'manifest', None, _(b'Display manifest statistics')),
3816 (b'f', b'filelogs', None, _(b'Display filelogs statistics')),
3817 ]
3818 + cmdutil.formatteropts,
3819 )
3820 def debug_revlog_stats(ui, repo, **opts):
3821 """display statistics about revlogs in the store"""
3822 opts = pycompat.byteskwargs(opts)
3823 changelog = opts[b"changelog"]
3824 manifest = opts[b"manifest"]
3825 filelogs = opts[b"filelogs"]
3826
3827 if changelog is None and manifest is None and filelogs is None:
3828 changelog = True
3829 manifest = True
3830 filelogs = True
3831
3832 repo = repo.unfiltered()
3833 fm = ui.formatter(b'debug-revlog-stats', opts)
3834 revlog_debug.debug_revlog_stats(repo, fm, changelog, manifest, filelogs)
3835 fm.end()
3836
3837
3838 @command(
3812 b'debugsuccessorssets',
3839 b'debugsuccessorssets',
3813 [(b'', b'closest', False, _(b'return closest successors sets only'))],
3840 [(b'', b'closest', False, _(b'return closest successors sets only'))],
3814 _(b'[REV]'),
3841 _(b'[REV]'),
@@ -661,3 +661,61 b' def debug_delta_find(ui, revlog, rev, ba'
661
661
662 fh = revlog._datafp()
662 fh = revlog._datafp()
663 deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev)
663 deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev)
664
665
666 def _get_revlogs(repo, changelog: bool, manifest: bool, filelogs: bool):
667 """yield revlogs from this repository"""
668 if changelog:
669 yield repo.changelog
670
671 if manifest:
672 # XXX: Handle tree manifest
673 root_mf = repo.manifestlog.getstorage(b'')
674 assert not root_mf._treeondisk
675 yield root_mf._revlog
676
677 if filelogs:
678 files = set()
679 for rev in repo:
680 ctx = repo[rev]
681 files |= set(ctx.files())
682
683 for f in sorted(files):
684 yield repo.file(f)._revlog
685
686
687 def debug_revlog_stats(
688 repo, fm, changelog: bool, manifest: bool, filelogs: bool
689 ):
690 """Format revlog statistics for debugging purposes
691
692 fm: the output formatter.
693 """
694 fm.plain(b'rev-count data-size inl type target \n')
695
696 for rlog in _get_revlogs(repo, changelog, manifest, filelogs):
697 fm.startitem()
698 nb_rev = len(rlog)
699 inline = rlog._inline
700 data_size = rlog._get_data_offset(nb_rev - 1)
701
702 target = rlog.target
703 revlog_type = b'unknown'
704 revlog_target = b''
705 if target[0] == constants.KIND_CHANGELOG:
706 revlog_type = b'changelog'
707 elif target[0] == constants.KIND_MANIFESTLOG:
708 revlog_type = b'manifest'
709 revlog_target = target[1]
710 elif target[0] == constants.KIND_FILELOG:
711 revlog_type = b'file'
712 revlog_target = target[1]
713
714 fm.write(b'revlog.rev-count', b'%9d', nb_rev)
715 fm.write(b'revlog.data-size', b'%12d', data_size)
716
717 fm.write(b'revlog.inline', b' %-3s', b'yes' if inline else b'no')
718 fm.write(b'revlog.type', b' %-9s', revlog_type)
719 fm.write(b'revlog.target', b' %s', revlog_target)
720
721 fm.plain(b'\n')
@@ -77,6 +77,7 b' Show debug commands if there are no othe'
77 debug-delta-find
77 debug-delta-find
78 debug-repair-issue6528
78 debug-repair-issue6528
79 debug-revlog-index
79 debug-revlog-index
80 debug-revlog-stats
80 debugancestor
81 debugancestor
81 debugantivirusrunning
82 debugantivirusrunning
82 debugapplystreamclonebundle
83 debugapplystreamclonebundle
@@ -271,6 +272,7 b' Show all commands + options'
271 debug-delta-find: changelog, manifest, dir, template, source
272 debug-delta-find: changelog, manifest, dir, template, source
272 debug-repair-issue6528: to-report, from-report, paranoid, dry-run
273 debug-repair-issue6528: to-report, from-report, paranoid, dry-run
273 debug-revlog-index: changelog, manifest, dir, template
274 debug-revlog-index: changelog, manifest, dir, template
275 debug-revlog-stats: changelog, manifest, filelogs, template
274 debugancestor:
276 debugancestor:
275 debugantivirusrunning:
277 debugantivirusrunning:
276 debugapplystreamclonebundle:
278 debugapplystreamclonebundle:
@@ -985,6 +985,8 b' Test list of internal help commands'
985 details.
985 details.
986 debug-revlog-index
986 debug-revlog-index
987 dump index data for a revlog
987 dump index data for a revlog
988 debug-revlog-stats
989 display statistics about revlogs in the store
988 debugancestor
990 debugancestor
989 find the ancestor revision of two revisions in a given index
991 find the ancestor revision of two revisions in a given index
990 debugantivirusrunning
992 debugantivirusrunning
General Comments 0
You need to be logged in to leave comments. Login now