annotate mercurial/revlogutils/debug.py @ 51708:3131445a831b

rust: use `.cargo/config.toml` instead of `.cargo/config` This has been deprecated for a while now and we don't support Rust versions that only understand the old path.
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 18 Jul 2024 13:36:32 +0200
parents df50a1592e0c
children 1c5810ce737e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
1 # revlogutils/debug.py - utility used for revlog debuging
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
2 #
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
4 # Copyright 2022 Octobus <contact@octobus.net>
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
5 #
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
8
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
9 import collections
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
10 import string
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
11
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
12 from .. import (
49676
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
13 mdiff,
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
14 node as nodemod,
49676
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
15 revlogutils,
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
16 )
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
17
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
18 from . import (
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
19 constants,
49676
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
20 deltas as deltautil,
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
21 )
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
22
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
23 INDEX_ENTRY_DEBUG_COLUMN = []
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
24
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
25 NODE_SIZE = object()
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
26
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
27
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
28 class _column_base:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
29 """constains the definition of a revlog column
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
30
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
31 name: the column header,
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
32 value_func: the function called to get a value,
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
33 size: the width of the column,
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
34 verbose_only: only include the column in verbose mode.
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
35 """
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
36
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
37 def __init__(self, name, value_func, size=None, verbose=False):
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
38 self.name = name
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
39 self.value_func = value_func
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
40 if size is not NODE_SIZE:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
41 if size is None:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
42 size = 8 # arbitrary default
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
43 size = max(len(name), size)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
44 self._size = size
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
45 self.verbose_only = verbose
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
46
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
47 def get_size(self, node_size):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
48 if self._size is NODE_SIZE:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
49 return node_size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
50 else:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
51 return self._size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
52
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
53
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
54 def debug_column(name, size=None, verbose=False):
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
55 """decorated function is registered as a column
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
56
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
57 name: the name of the column,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
58 size: the expected size of the column.
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
59 """
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
60
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
61 def register(func):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
62 entry = _column_base(
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
63 name=name,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
64 value_func=func,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
65 size=size,
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
66 verbose=verbose,
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
67 )
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
68 INDEX_ENTRY_DEBUG_COLUMN.append(entry)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
69 return entry
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
70
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
71 return register
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
72
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
73
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
74 @debug_column(b"rev", size=6)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
75 def _rev(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
76 return b"%d" % rev
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
77
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
78
49266
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49265
diff changeset
79 @debug_column(b"rank", size=6, verbose=True)
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49265
diff changeset
80 def rank(index, rev, entry, hexfn):
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49265
diff changeset
81 return b"%d" % entry[constants.ENTRY_RANK]
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49265
diff changeset
82
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49265
diff changeset
83
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
84 @debug_column(b"linkrev", size=6)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
85 def _linkrev(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
86 return b"%d" % entry[constants.ENTRY_LINK_REV]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
87
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
88
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
89 @debug_column(b"nodeid", size=NODE_SIZE)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
90 def _nodeid(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
91 return hexfn(entry[constants.ENTRY_NODE_ID])
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
92
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
93
49255
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49254
diff changeset
94 @debug_column(b"p1-rev", size=6, verbose=True)
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49254
diff changeset
95 def _p1_rev(index, rev, entry, hexfn):
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49254
diff changeset
96 return b"%d" % entry[constants.ENTRY_PARENT_1]
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49254
diff changeset
97
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49254
diff changeset
98
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
99 @debug_column(b"p1-nodeid", size=NODE_SIZE)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
100 def _p1_node(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
101 parent = entry[constants.ENTRY_PARENT_1]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
102 p_entry = index[parent]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
103 return hexfn(p_entry[constants.ENTRY_NODE_ID])
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
104
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
105
49256
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49255
diff changeset
106 @debug_column(b"p2-rev", size=6, verbose=True)
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49255
diff changeset
107 def _p2_rev(index, rev, entry, hexfn):
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49255
diff changeset
108 return b"%d" % entry[constants.ENTRY_PARENT_2]
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49255
diff changeset
109
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49255
diff changeset
110
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
111 @debug_column(b"p2-nodeid", size=NODE_SIZE)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
112 def _p2_node(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
113 parent = entry[constants.ENTRY_PARENT_2]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
114 p_entry = index[parent]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
115 return hexfn(p_entry[constants.ENTRY_NODE_ID])
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
116
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
117
49257
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49256
diff changeset
118 @debug_column(b"full-size", size=20, verbose=True)
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49256
diff changeset
119 def full_size(index, rev, entry, hexfn):
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49256
diff changeset
120 return b"%d" % entry[constants.ENTRY_DATA_UNCOMPRESSED_LENGTH]
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49256
diff changeset
121
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49256
diff changeset
122
49258
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49257
diff changeset
123 @debug_column(b"delta-base", size=6, verbose=True)
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49257
diff changeset
124 def delta_base(index, rev, entry, hexfn):
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49257
diff changeset
125 return b"%d" % entry[constants.ENTRY_DELTA_BASE]
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49257
diff changeset
126
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49257
diff changeset
127
49259
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
128 @debug_column(b"flags", size=2, verbose=True)
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
129 def flags(index, rev, entry, hexfn):
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
130 field = entry[constants.ENTRY_DATA_OFFSET]
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
131 field &= 0xFFFF
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
132 return b"%d" % field
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
133
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
134
49260
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49259
diff changeset
135 @debug_column(b"comp-mode", size=4, verbose=True)
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49259
diff changeset
136 def compression_mode(index, rev, entry, hexfn):
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49259
diff changeset
137 return b"%d" % entry[constants.ENTRY_DATA_COMPRESSION_MODE]
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49259
diff changeset
138
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49259
diff changeset
139
49261
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49260
diff changeset
140 @debug_column(b"data-offset", size=20, verbose=True)
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49260
diff changeset
141 def data_offset(index, rev, entry, hexfn):
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49260
diff changeset
142 field = entry[constants.ENTRY_DATA_OFFSET]
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49260
diff changeset
143 field >>= 16
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49260
diff changeset
144 return b"%d" % field
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49260
diff changeset
145
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49260
diff changeset
146
49262
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49261
diff changeset
147 @debug_column(b"chunk-size", size=10, verbose=True)
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49261
diff changeset
148 def data_chunk_size(index, rev, entry, hexfn):
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49261
diff changeset
149 return b"%d" % entry[constants.ENTRY_DATA_COMPRESSED_LENGTH]
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49261
diff changeset
150
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49261
diff changeset
151
49263
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
152 @debug_column(b"sd-comp-mode", size=7, verbose=True)
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
153 def sidedata_compression_mode(index, rev, entry, hexfn):
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
154 compression = entry[constants.ENTRY_SIDEDATA_COMPRESSION_MODE]
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
155 if compression == constants.COMP_MODE_PLAIN:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
156 return b"plain"
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
157 elif compression == constants.COMP_MODE_DEFAULT:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
158 return b"default"
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
159 elif compression == constants.COMP_MODE_INLINE:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
160 return b"inline"
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
161 else:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
162 return b"%d" % compression
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
163
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49262
diff changeset
164
49264
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49263
diff changeset
165 @debug_column(b"sidedata-offset", size=20, verbose=True)
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49263
diff changeset
166 def sidedata_offset(index, rev, entry, hexfn):
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49263
diff changeset
167 return b"%d" % entry[constants.ENTRY_SIDEDATA_OFFSET]
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49263
diff changeset
168
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49263
diff changeset
169
49265
30d2beab8163 debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49264
diff changeset
170 @debug_column(b"sd-chunk-size", size=10, verbose=True)
30d2beab8163 debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49264
diff changeset
171 def sidedata_chunk_size(index, rev, entry, hexfn):
30d2beab8163 debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49264
diff changeset
172 return b"%d" % entry[constants.ENTRY_SIDEDATA_COMPRESSED_LENGTH]
30d2beab8163 debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49264
diff changeset
173
30d2beab8163 debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49264
diff changeset
174
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
175 def debug_index(
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
176 ui,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
177 repo,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
178 formatter,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
179 revlog,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
180 full_node,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
181 ):
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
182 """display index data for a revlog"""
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
183 if full_node:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
184 hexfn = nodemod.hex
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
185 else:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
186 hexfn = nodemod.short
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
187
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
188 idlen = 12
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
189 for i in revlog:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
190 idlen = len(hexfn(revlog.node(i)))
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
191 break
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
192
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
193 fm = formatter
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
194
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
195 header_pieces = []
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
196 for column in INDEX_ENTRY_DEBUG_COLUMN:
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
197 if column.verbose_only and not ui.verbose:
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
198 continue
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
199 size = column.get_size(idlen)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
200 name = column.name
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
201 header_pieces.append(name.rjust(size))
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
202
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
203 fm.plain(b' '.join(header_pieces) + b'\n')
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
204
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
205 index = revlog.index
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
206
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
207 for rev in revlog:
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
208 fm.startitem()
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
209 entry = index[rev]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
210 first = True
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
211 for column in INDEX_ENTRY_DEBUG_COLUMN:
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
212 if column.verbose_only and not ui.verbose:
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
213 continue
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
214 if not first:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
215 fm.plain(b' ')
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
216 first = False
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
217
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
218 size = column.get_size(idlen)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
219 value = column.value_func(index, rev, entry, hexfn)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
220 display = b"%%%ds" % size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
221 fm.write(column.name, display, value)
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
222 fm.plain(b'\n')
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
223
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
224 fm.end()
49659
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
225
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
226
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
227 def dump(ui, revlog):
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
228 """perform the work for `hg debugrevlog --dump"""
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
229 # XXX seems redundant with debug index ?
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
230 r = revlog
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
231 numrevs = len(r)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
232 ui.write(
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
233 (
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
234 b"# rev p1rev p2rev start end deltastart base p1 p2"
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
235 b" rawsize totalsize compression heads chainlen\n"
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
236 )
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
237 )
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
238 ts = 0
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
239 heads = set()
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
240
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
241 for rev in range(numrevs):
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
242 dbase = r.deltaparent(rev)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
243 if dbase == -1:
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
244 dbase = rev
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
245 cbase = r.chainbase(rev)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
246 clen = r.chainlen(rev)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
247 p1, p2 = r.parentrevs(rev)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
248 rs = r.rawsize(rev)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
249 ts = ts + rs
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
250 heads -= set(r.parentrevs(rev))
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
251 heads.add(rev)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
252 try:
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
253 compression = ts / r.end(rev)
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
254 except ZeroDivisionError:
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
255 compression = 0
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
256 ui.write(
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
257 b"%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
258 b"%11d %5d %8d\n"
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
259 % (
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
260 rev,
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
261 p1,
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
262 p2,
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
263 r.start(rev),
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
264 r.end(rev),
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
265 r.start(dbase),
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
266 r.start(cbase),
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
267 r.start(p1),
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
268 r.start(p2),
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
269 rs,
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
270 ts,
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
271 compression,
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
272 len(heads),
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
273 clen,
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
274 )
7c0a383849a8 debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49266
diff changeset
275 )
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
276
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
277
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
278 def debug_revlog(ui, revlog):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
279 """code for `hg debugrevlog`"""
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
280 r = revlog
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
281 format = r._format_version
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
282 v = r._format_flags
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
283 flags = []
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
284 gdelta = False
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
285 if v & constants.FLAG_INLINE_DATA:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
286 flags.append(b'inline')
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
287 if v & constants.FLAG_GENERALDELTA:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
288 gdelta = True
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
289 flags.append(b'generaldelta')
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
290 if not flags:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
291 flags = [b'(none)']
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
292
49662
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
293 ### the total size of stored content if incompressed.
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
294 full_text_total_size = 0
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
295 ### tracks merge vs single parent
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
296 nummerges = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
297
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
298 ### tracks ways the "delta" are build
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
299 # nodelta
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
300 numempty = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
301 numemptytext = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
302 numemptydelta = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
303 # full file content
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
304 numfull = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
305 # intermediate snapshot against a prior snapshot
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
306 numsemi = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
307 # snapshot count per depth
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
308 numsnapdepth = collections.defaultdict(lambda: 0)
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
309 # number of snapshots with a non-ancestor delta
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
310 numsnapdepth_nad = collections.defaultdict(lambda: 0)
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
311 # delta against previous revision
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
312 numprev = 0
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
313 # delta against prev, where prev is a non-ancestor
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
314 numprev_nad = 0
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
315 # delta against first or second parent (not prev)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
316 nump1 = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
317 nump2 = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
318 # delta against neither prev nor parents
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
319 numother = 0
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
320 # delta against other that is a non-ancestor
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
321 numother_nad = 0
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
322 # delta against prev that are also first or second parent
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
323 # (details of `numprev`)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
324 nump1prev = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
325 nump2prev = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
326
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
327 # data about delta chain of each revs
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
328 chainlengths = []
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
329 chainbases = []
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
330 chainspans = []
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
331
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
332 # data about each revision
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
333 datasize = [None, 0, 0]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
334 fullsize = [None, 0, 0]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
335 semisize = [None, 0, 0]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
336 # snapshot count per depth
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
337 snapsizedepth = collections.defaultdict(lambda: [None, 0, 0])
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
338 deltasize = [None, 0, 0]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
339 chunktypecounts = {}
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
340 chunktypesizes = {}
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
341
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
342 def addsize(size, l):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
343 if l[0] is None or size < l[0]:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
344 l[0] = size
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
345 if size > l[1]:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
346 l[1] = size
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
347 l[2] += size
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
348
51017
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
349 with r.reading():
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
350 numrevs = len(r)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
351 for rev in range(numrevs):
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
352 p1, p2 = r.parentrevs(rev)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
353 delta = r.deltaparent(rev)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
354 if format > 0:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
355 s = r.rawsize(rev)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
356 full_text_total_size += s
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
357 addsize(s, datasize)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
358 if p2 != nodemod.nullrev:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
359 nummerges += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
360 size = r.length(rev)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
361 if delta == nodemod.nullrev:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
362 chainlengths.append(0)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
363 chainbases.append(r.start(rev))
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
364 chainspans.append(size)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
365 if size == 0:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
366 numempty += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
367 numemptytext += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
368 else:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
369 numfull += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
370 numsnapdepth[0] += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
371 addsize(size, fullsize)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
372 addsize(size, snapsizedepth[0])
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
373 else:
51017
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
374 nad = (
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
375 delta != p1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
376 and delta != p2
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
377 and not r.isancestorrev(delta, rev)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
378 )
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
379 chainlengths.append(chainlengths[delta] + 1)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
380 baseaddr = chainbases[delta]
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
381 revaddr = r.start(rev)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
382 chainbases.append(baseaddr)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
383 chainspans.append((revaddr - baseaddr) + size)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
384 if size == 0:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
385 numempty += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
386 numemptydelta += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
387 elif r.issnapshot(rev):
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
388 addsize(size, semisize)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
389 numsemi += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
390 depth = r.snapshotdepth(rev)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
391 numsnapdepth[depth] += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
392 if nad:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
393 numsnapdepth_nad[depth] += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
394 addsize(size, snapsizedepth[depth])
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
395 else:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
396 addsize(size, deltasize)
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
397 if delta == rev - 1:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
398 numprev += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
399 if delta == p1:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
400 nump1prev += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
401 elif delta == p2:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
402 nump2prev += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
403 elif nad:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
404 numprev_nad += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
405 elif delta == p1:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
406 nump1 += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
407 elif delta == p2:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
408 nump2 += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
409 elif delta != nodemod.nullrev:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
410 numother += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
411 numother_nad += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
412
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
413 # Obtain data on the raw chunks in the revlog.
51087
df50a1592e0c revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51074
diff changeset
414 if hasattr(r, '_inner'):
df50a1592e0c revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51074
diff changeset
415 segment = r._inner.get_segment_for_revs(rev, rev)[1]
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
416 else:
51017
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
417 segment = r._revlog._getsegmentforrevs(rev, rev)[1]
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
418 if segment:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
419 chunktype = bytes(segment[0:1])
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
420 else:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
421 chunktype = b'empty'
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
422
51017
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
423 if chunktype not in chunktypecounts:
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
424 chunktypecounts[chunktype] = 0
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
425 chunktypesizes[chunktype] = 0
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
426
51017
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
427 chunktypecounts[chunktype] += 1
edc44ab7437a debug-revlog: keep the revlog open for the analysis duration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50928
diff changeset
428 chunktypesizes[chunktype] += size
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
429
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
430 # Adjust size min value for empty cases
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
431 for size in (datasize, fullsize, semisize, deltasize):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
432 if size[0] is None:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
433 size[0] = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
434
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
435 numdeltas = numrevs - numfull - numempty - numsemi
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
436 numoprev = numprev - nump1prev - nump2prev - numprev_nad
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
437 num_other_ancestors = numother - numother_nad
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
438 totalrawsize = datasize[2]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
439 datasize[2] /= numrevs
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
440 fulltotal = fullsize[2]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
441 if numfull == 0:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
442 fullsize[2] = 0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
443 else:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
444 fullsize[2] /= numfull
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
445 semitotal = semisize[2]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
446 snaptotal = {}
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
447 if numsemi > 0:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
448 semisize[2] /= numsemi
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
449 for depth in snapsizedepth:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
450 snaptotal[depth] = snapsizedepth[depth][2]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
451 snapsizedepth[depth][2] /= numsnapdepth[depth]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
452
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
453 deltatotal = deltasize[2]
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
454 if numdeltas > 0:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
455 deltasize[2] /= numdeltas
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
456 totalsize = fulltotal + semitotal + deltatotal
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
457 avgchainlen = sum(chainlengths) / numrevs
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
458 maxchainlen = max(chainlengths)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
459 maxchainspan = max(chainspans)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
460 compratio = 1
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
461 if totalsize:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
462 compratio = totalrawsize / totalsize
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
463
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
464 basedfmtstr = b'%%%dd\n'
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
465 basepcfmtstr = b'%%%dd %s(%%5.2f%%%%)\n'
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
466
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
467 def dfmtstr(max):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
468 return basedfmtstr % len(str(max))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
469
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
470 def pcfmtstr(max, padding=0):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
471 return basepcfmtstr % (len(str(max)), b' ' * padding)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
472
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
473 def pcfmt(value, total):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
474 if total:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
475 return (value, 100 * float(value) / total)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
476 else:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
477 return value, 100.0
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
478
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
479 ui.writenoi18n(b'format : %d\n' % format)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
480 ui.writenoi18n(b'flags : %s\n' % b', '.join(flags))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
481
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
482 ui.write(b'\n')
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
483 fmt = pcfmtstr(totalsize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
484 fmt2 = dfmtstr(totalsize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
485 ui.writenoi18n(b'revisions : ' + fmt2 % numrevs)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
486 ui.writenoi18n(b' merges : ' + fmt % pcfmt(nummerges, numrevs))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
487 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
488 b' normal : ' + fmt % pcfmt(numrevs - nummerges, numrevs)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
489 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
490 ui.writenoi18n(b'revisions : ' + fmt2 % numrevs)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
491 ui.writenoi18n(b' empty : ' + fmt % pcfmt(numempty, numrevs))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
492 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
493 b' text : '
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
494 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
495 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
496 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
497 b' delta : '
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
498 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
499 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
500 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
501 b' snapshot : ' + fmt % pcfmt(numfull + numsemi, numrevs)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
502 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
503 for depth in sorted(numsnapdepth):
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
504 base = b' lvl-%-3d : ' % depth
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
505 count = fmt % pcfmt(numsnapdepth[depth], numrevs)
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
506 pieces = [base, count]
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
507 if numsnapdepth_nad[depth]:
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
508 pieces[-1] = count = count[:-1] # drop the final '\n'
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
509 more = b' non-ancestor-bases: '
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
510 anc_count = fmt
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
511 anc_count %= pcfmt(numsnapdepth_nad[depth], numsnapdepth[depth])
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
512 pieces.append(more)
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
513 pieces.append(anc_count)
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
514 ui.write(b''.join(pieces))
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
515 ui.writenoi18n(b' deltas : ' + fmt % pcfmt(numdeltas, numrevs))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
516 ui.writenoi18n(b'revision size : ' + fmt2 % totalsize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
517 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
518 b' snapshot : ' + fmt % pcfmt(fulltotal + semitotal, totalsize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
519 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
520 for depth in sorted(numsnapdepth):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
521 ui.write(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
522 (b' lvl-%-3d : ' % depth)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
523 + fmt % pcfmt(snaptotal[depth], totalsize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
524 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
525 ui.writenoi18n(b' deltas : ' + fmt % pcfmt(deltatotal, totalsize))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
526
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
527 letters = string.ascii_letters.encode('ascii')
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
528
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
529 def fmtchunktype(chunktype):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
530 if chunktype == b'empty':
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
531 return b' %s : ' % chunktype
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
532 elif chunktype in letters:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
533 return b' 0x%s (%s) : ' % (nodemod.hex(chunktype), chunktype)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
534 else:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
535 return b' 0x%s : ' % nodemod.hex(chunktype)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
536
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
537 ui.write(b'\n')
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
538 ui.writenoi18n(b'chunks : ' + fmt2 % numrevs)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
539 for chunktype in sorted(chunktypecounts):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
540 ui.write(fmtchunktype(chunktype))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
541 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
542 ui.writenoi18n(b'chunks size : ' + fmt2 % totalsize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
543 for chunktype in sorted(chunktypecounts):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
544 ui.write(fmtchunktype(chunktype))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
545 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
546
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
547 ui.write(b'\n')
49662
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
548 b_total = b"%d" % full_text_total_size
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
549 p_total = []
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
550 while len(b_total) > 3:
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
551 p_total.append(b_total[-3:])
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
552 b_total = b_total[:-3]
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
553 p_total.append(b_total)
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
554 p_total.reverse()
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
555 b_total = b' '.join(p_total)
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
556
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
557 ui.write(b'\n')
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
558 ui.writenoi18n(b'total-stored-content: %s bytes\n' % b_total)
7aea9babac5d debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49661
diff changeset
559 ui.write(b'\n')
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
560 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
561 ui.writenoi18n(b'avg chain length : ' + fmt % avgchainlen)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
562 ui.writenoi18n(b'max chain length : ' + fmt % maxchainlen)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
563 ui.writenoi18n(b'max chain reach : ' + fmt % maxchainspan)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
564 ui.writenoi18n(b'compression ratio : ' + fmt % compratio)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
565
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
566 if format > 0:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
567 ui.write(b'\n')
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
568 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
569 b'uncompressed data size (min/max/avg) : %d / %d / %d\n'
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
570 % tuple(datasize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
571 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
572 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
573 b'full revision size (min/max/avg) : %d / %d / %d\n'
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
574 % tuple(fullsize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
575 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
576 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
577 b'inter-snapshot size (min/max/avg) : %d / %d / %d\n'
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
578 % tuple(semisize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
579 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
580 for depth in sorted(snapsizedepth):
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
581 if depth == 0:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
582 continue
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
583 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
584 b' level-%-3d (min/max/avg) : %d / %d / %d\n'
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
585 % ((depth,) + tuple(snapsizedepth[depth]))
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
586 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
587 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
588 b'delta size (min/max/avg) : %d / %d / %d\n'
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
589 % tuple(deltasize)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
590 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
591
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
592 if numdeltas > 0:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
593 ui.write(b'\n')
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
594 fmt = pcfmtstr(numdeltas)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
595 fmt2 = pcfmtstr(numdeltas, 4)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
596 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
597 b'deltas against prev : ' + fmt % pcfmt(numprev, numdeltas)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
598 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
599 if numprev > 0:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
600 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
601 b' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
602 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
603 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
604 b' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
605 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
606 ui.writenoi18n(
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
607 b' other-ancestor : ' + fmt2 % pcfmt(numoprev, numprev)
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
608 )
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
609 ui.writenoi18n(
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
610 b' unrelated : ' + fmt2 % pcfmt(numoprev, numprev)
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
611 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
612 if gdelta:
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
613 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
614 b'deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
615 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
616 ui.writenoi18n(
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
617 b'deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas)
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
618 )
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
619 ui.writenoi18n(
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
620 b'deltas against ancs : '
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
621 + fmt % pcfmt(num_other_ancestors, numdeltas)
49660
bd3b6f363fb9 debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49659
diff changeset
622 )
49661
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
623 ui.writenoi18n(
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
624 b'deltas against other : '
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
625 + fmt % pcfmt(numother_nad, numdeltas)
511106bcb16c debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49660
diff changeset
626 )
49676
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
627
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
628
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
629 def debug_delta_find(ui, revlog, rev, base_rev=nodemod.nullrev):
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
630 """display the search process for a delta"""
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
631 deltacomputer = deltautil.deltacomputer(
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
632 revlog,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
633 write_debug=ui.write,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
634 debug_search=not ui.quiet,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
635 )
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
636
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
637 node = revlog.node(rev)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
638 p1r, p2r = revlog.parentrevs(rev)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
639 p1 = revlog.node(p1r)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
640 p2 = revlog.node(p2r)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
641 full_text = revlog.revision(rev)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
642 btext = [full_text]
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
643 textlen = len(btext[0])
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
644 cachedelta = None
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
645 flags = revlog.flags(rev)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
646
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
647 if base_rev != nodemod.nullrev:
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
648 base_text = revlog.revision(base_rev)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
649 delta = mdiff.textdiff(base_text, full_text)
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
650
49677
05db41701ece find-delta: pass the cache-delta usage policy alongside the cache-delta
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49676
diff changeset
651 cachedelta = (base_rev, delta, constants.DELTA_BASE_REUSE_TRY)
49676
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
652 btext = [None]
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
653
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
654 revinfo = revlogutils.revisioninfo(
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
655 node,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
656 p1,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
657 p2,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
658 btext,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
659 textlen,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
660 cachedelta,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
661 flags,
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
662 )
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
663
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
664 fh = revlog._datafp()
4302db0f54c8 find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49662
diff changeset
665 deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev)
49819
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
666
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
667
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
668 def debug_revlog_stats(
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
669 repo, fm, changelog: bool, manifest: bool, filelogs: bool
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
670 ):
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
671 """Format revlog statistics for debugging purposes
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
672
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
673 fm: the output formatter.
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
674 """
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
675 fm.plain(b'rev-count data-size inl type target \n')
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
676
50681
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
677 revlog_entries = [e for e in repo.store.walk() if e.is_revlog]
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
678 revlog_entries.sort(key=lambda e: (e.revlog_type, e.target_id))
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
679
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
680 for entry in revlog_entries:
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
681 if not changelog and entry.is_changelog:
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
682 continue
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
683 elif not manifest and entry.is_manifestlog:
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
684 continue
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
685 elif not filelogs and entry.is_filelog:
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
686 continue
47b44d80d836 debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49819
diff changeset
687 rlog = entry.get_revlog_instance(repo).get_revlog()
49819
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
688 fm.startitem()
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
689 nb_rev = len(rlog)
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
690 inline = rlog._inline
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
691 data_size = rlog._get_data_offset(nb_rev - 1)
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
692
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
693 target = rlog.target
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
694 revlog_type = b'unknown'
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
695 revlog_target = b''
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
696 if target[0] == constants.KIND_CHANGELOG:
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
697 revlog_type = b'changelog'
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
698 elif target[0] == constants.KIND_MANIFESTLOG:
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
699 revlog_type = b'manifest'
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
700 revlog_target = target[1]
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
701 elif target[0] == constants.KIND_FILELOG:
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
702 revlog_type = b'file'
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
703 revlog_target = target[1]
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
704
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
705 fm.write(b'revlog.rev-count', b'%9d', nb_rev)
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
706 fm.write(b'revlog.data-size', b'%12d', data_size)
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
707
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
708 fm.write(b'revlog.inline', b' %-3s', b'yes' if inline else b'no')
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
709 fm.write(b'revlog.type', b' %-9s', revlog_type)
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
710 fm.write(b'revlog.target', b' %s', revlog_target)
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
711
b1e4c74beb6f debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents: 49677
diff changeset
712 fm.plain(b'\n')
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
713
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
714
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
715 class DeltaChainAuditor:
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
716 def __init__(self, revlog):
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
717 self._revlog = revlog
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
718 self._index = self._revlog.index
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
719 self._generaldelta = revlog.delta_config.general_delta
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
720 self._chain_size_cache = {}
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
721 # security to avoid crash on corrupted revlogs
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
722 self._total_revs = len(self._index)
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
723
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
724 def revinfo(self, rev, size_info=True, dist_info=True, sparse_info=True):
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
725 e = self._index[rev]
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
726 compsize = e[constants.ENTRY_DATA_COMPRESSED_LENGTH]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
727 uncompsize = e[constants.ENTRY_DATA_UNCOMPRESSED_LENGTH]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
728
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
729 base = e[constants.ENTRY_DELTA_BASE]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
730 p1 = e[constants.ENTRY_PARENT_1]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
731 p2 = e[constants.ENTRY_PARENT_2]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
732
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
733 # If the parents of a revision has an empty delta, we never try to
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
734 # delta against that parent, but directly against the delta base of
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
735 # that parent (recursively). It avoids adding a useless entry in the
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
736 # chain.
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
737 #
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
738 # However we need to detect that as a special case for delta-type, that
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
739 # is not simply "other".
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
740 p1_base = p1
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
741 if p1 != nodemod.nullrev and p1 < self._total_revs:
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
742 e1 = self._index[p1]
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
743 while e1[constants.ENTRY_DATA_COMPRESSED_LENGTH] == 0:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
744 new_base = e1[constants.ENTRY_DELTA_BASE]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
745 if (
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
746 new_base == p1_base
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
747 or new_base == nodemod.nullrev
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
748 or new_base >= self._total_revs
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
749 ):
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
750 break
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
751 p1_base = new_base
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
752 e1 = self._index[p1_base]
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
753 p2_base = p2
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
754 if p2 != nodemod.nullrev and p2 < self._total_revs:
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
755 e2 = self._index[p2]
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
756 while e2[constants.ENTRY_DATA_COMPRESSED_LENGTH] == 0:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
757 new_base = e2[constants.ENTRY_DELTA_BASE]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
758 if (
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
759 new_base == p2_base
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
760 or new_base == nodemod.nullrev
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
761 or new_base >= self._total_revs
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
762 ):
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
763 break
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
764 p2_base = new_base
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
765 e2 = self._index[p2_base]
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
766
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
767 if self._generaldelta:
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
768 if base == p1:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
769 deltatype = b'p1'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
770 elif base == p2:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
771 deltatype = b'p2'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
772 elif base == rev:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
773 deltatype = b'base'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
774 elif base == p1_base:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
775 deltatype = b'skip1'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
776 elif base == p2_base:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
777 deltatype = b'skip2'
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
778 elif self._revlog.issnapshot(rev):
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
779 deltatype = b'snap'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
780 elif base == rev - 1:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
781 deltatype = b'prev'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
782 else:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
783 deltatype = b'other'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
784 else:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
785 if base == rev:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
786 deltatype = b'base'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
787 else:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
788 deltatype = b'prev'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
789
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
790 chain = self._revlog._deltachain(rev)[0]
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
791
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
792 data = {
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
793 'p1': p1,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
794 'p2': p2,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
795 'compressed_size': compsize,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
796 'uncompressed_size': uncompsize,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
797 'deltatype': deltatype,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
798 'chain': chain,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
799 }
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
800
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
801 if size_info or dist_info or sparse_info:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
802 chain_size = 0
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
803 for iter_rev in reversed(chain):
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
804 cached = self._chain_size_cache.get(iter_rev)
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
805 if cached is not None:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
806 chain_size += cached
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
807 break
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
808 e = self._index[iter_rev]
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
809 chain_size += e[constants.ENTRY_DATA_COMPRESSED_LENGTH]
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
810 self._chain_size_cache[rev] = chain_size
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
811 data['chain_size'] = chain_size
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
812
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
813 return data
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
814
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
815
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
816 def debug_delta_chain(
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
817 revlog,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
818 revs=None,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
819 size_info=True,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
820 dist_info=True,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
821 sparse_info=True,
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
822 ):
51071
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
823 auditor = DeltaChainAuditor(revlog)
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
824 r = revlog
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
825 start = r.start
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
826 length = r.length
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
827 withsparseread = revlog.data_config.with_sparse_read
793a058f64bd delta-chain: extract some debugdeltachain logic is object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51070
diff changeset
828
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
829 header = (
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
830 b' rev'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
831 b' p1'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
832 b' p2'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
833 b' chain#'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
834 b' chainlen'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
835 b' prev'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
836 b' delta'
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
837 )
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
838 if size_info:
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
839 header += b' size' b' rawsize' b' chainsize' b' ratio'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
840 if dist_info:
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
841 header += b' lindist' b' extradist' b' extraratio'
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
842 if withsparseread and sparse_info:
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
843 header += b' readsize' b' largestblk' b' rddensity' b' srchunks'
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
844 header += b'\n'
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
845 yield header
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
846
51072
810446d2d5ef debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51071
diff changeset
847 if revs is None:
810446d2d5ef debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51071
diff changeset
848 all_revs = iter(r)
810446d2d5ef debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51071
diff changeset
849 else:
810446d2d5ef debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51071
diff changeset
850 revlog_size = len(r)
810446d2d5ef debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51071
diff changeset
851 all_revs = sorted(rev for rev in revs if rev < revlog_size)
810446d2d5ef debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51071
diff changeset
852
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
853 chainbases = {}
51072
810446d2d5ef debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51071
diff changeset
854 for rev in all_revs:
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
855 info = auditor.revinfo(
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
856 rev,
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
857 size_info=size_info,
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
858 dist_info=dist_info,
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
859 sparse_info=sparse_info,
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
860 )
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
861 comp = info['compressed_size']
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
862 uncomp = info['uncompressed_size']
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
863 chain = info['chain']
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
864 chainbase = chain[0]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
865 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
866 if dist_info:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
867 basestart = start(chainbase)
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
868 revstart = start(rev)
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
869 lineardist = revstart + comp - basestart
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
870 extradist = lineardist - info['chain_size']
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
871 try:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
872 prevrev = chain[-2]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
873 except IndexError:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
874 prevrev = -1
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
875
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
876 if size_info:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
877 chainsize = info['chain_size']
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
878 if uncomp != 0:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
879 chainratio = float(chainsize) / float(uncomp)
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
880 else:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
881 chainratio = chainsize
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
882
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
883 if dist_info:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
884 if chainsize != 0:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
885 extraratio = float(extradist) / float(chainsize)
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
886 else:
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
887 extraratio = extradist
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
888
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
889 # label, display-format, data-key, value
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
890 entry = [
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
891 (b'rev', b'%7d', 'rev', rev),
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
892 (b'p1', b'%7d', 'p1', info['p1']),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
893 (b'p2', b'%7d', 'p2', info['p2']),
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
894 (b'chainid', b'%7d', 'chainid', chainid),
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
895 (b'chainlen', b'%8d', 'chainlen', len(chain)),
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
896 (b'prevrev', b'%8d', 'prevrev', prevrev),
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
897 (b'deltatype', b'%7s', 'deltatype', info['deltatype']),
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
898 ]
51073
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
899 if size_info:
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
900 entry.extend(
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
901 [
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
902 (b'compsize', b'%10d', 'compsize', comp),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
903 (b'uncompsize', b'%10d', 'uncompsize', uncomp),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
904 (b'chainsize', b'%10d', 'chainsize', chainsize),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
905 (b'chainratio', b'%9.5f', 'chainratio', chainratio),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
906 ]
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
907 )
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
908 if dist_info:
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
909 entry.extend(
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
910 [
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
911 (b'lindist', b'%9d', 'lindist', lineardist),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
912 (b'extradist', b'%9d', 'extradist', extradist),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
913 (b'extraratio', b'%10.5f', 'extraratio', extraratio),
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
914 ]
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
915 )
752e380c5702 debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51072
diff changeset
916 if withsparseread and sparse_info:
51074
5b5cb6b833b0 debug-delta-chain: actually skip unrequested computation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51073
diff changeset
917 chainsize = info['chain_size']
51070
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
918 readsize = 0
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
919 largestblock = 0
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
920 srchunks = 0
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
921
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
922 for revschunk in deltautil.slicechunk(r, chain):
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
923 srchunks += 1
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
924 blkend = start(revschunk[-1]) + length(revschunk[-1])
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
925 blksize = blkend - start(revschunk[0])
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
926
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
927 readsize += blksize
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
928 if largestblock < blksize:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
929 largestblock = blksize
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
930
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
931 if readsize:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
932 readdensity = float(chainsize) / float(readsize)
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
933 else:
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
934 readdensity = 1
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
935 entry.extend(
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
936 [
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
937 (b'readsize', b'%10d', 'readsize', readsize),
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
938 (b'largestblock', b'%10d', 'largestblock', largestblock),
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
939 (b'readdensity', b'%9.5f', 'readdensity', readdensity),
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
940 (b'srchunks', b'%8d', 'srchunks', srchunks),
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
941 ]
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
942 )
d7f975e49f20 delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51017
diff changeset
943 yield entry