annotate mercurial/revlogutils/debug.py @ 49320:fce591256085

commit: remove special handling of IOError (actually dead code) In the past, IOError was used to mark a file as removed. The differentiation between OSError and IOError in this place was introduced in e553a425751d, to avoid that “normal” OSErrors / IOErrors accidentally mark files as removed. This weird internal API was removed in 650b5b6e75ed. It seems like that changeset should have removed the differentiation, at least I don’t see any reason for keeping it. On Python 3, OSError and IOError are aliased. Therefore the removed code was actually dead.
author Manuel Jacob <me@manueljacob.de>
date Wed, 01 Jun 2022 01:30:48 +0200
parents da3e37ecacde
children 7c0a383849a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49265
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
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
9 from .. import (
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
10 node as nodemod,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
11 )
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
12
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
13 from . import (
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
14 constants,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
15 )
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
16
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
17 INDEX_ENTRY_DEBUG_COLUMN = []
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
18
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
19 NODE_SIZE = object()
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
20
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
21
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
22 class _column_base:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
23 """constains the definition of a revlog column
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
24
49269
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
25 name: the column header,
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
26 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: 49268
diff changeset
27 size: the width of the column,
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
28 verbose_only: only include the column in verbose mode.
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
29 """
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
30
49269
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
31 def __init__(self, name, value_func, size=None, verbose=False):
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
32 self.name = name
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
33 self.value_func = value_func
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
34 if size is not NODE_SIZE:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
35 if size is None:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
36 size = 8 # arbitrary default
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
37 size = max(len(name), size)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
38 self._size = size
49269
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
39 self.verbose_only = verbose
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
40
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
41 def get_size(self, node_size):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
42 if self._size is NODE_SIZE:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
43 return node_size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
44 else:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
45 return self._size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
46
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
47
49269
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
48 def debug_column(name, size=None, verbose=False):
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
49 """decorated function is registered as a column
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
50
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
51 name: the name of the column,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
52 size: the expected size of the column.
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
53 """
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
54
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
55 def register(func):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
56 entry = _column_base(
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
57 name=name,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
58 value_func=func,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
59 size=size,
49269
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
60 verbose=verbose,
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
61 )
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
62 INDEX_ENTRY_DEBUG_COLUMN.append(entry)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
63 return entry
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
64
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
65 return register
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
66
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
67
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
68 @debug_column(b"rev", size=6)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
69 def _rev(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
70 return b"%d" % rev
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
71
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
72
49281
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49280
diff changeset
73 @debug_column(b"rank", size=6, verbose=True)
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49280
diff changeset
74 def rank(index, rev, entry, hexfn):
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49280
diff changeset
75 return b"%d" % entry[constants.ENTRY_RANK]
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49280
diff changeset
76
da3e37ecacde debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49280
diff changeset
77
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
78 @debug_column(b"linkrev", size=6)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
79 def _linkrev(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
80 return b"%d" % entry[constants.ENTRY_LINK_REV]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
81
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
82
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
83 @debug_column(b"nodeid", size=NODE_SIZE)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
84 def _nodeid(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
85 return hexfn(entry[constants.ENTRY_NODE_ID])
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
86
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
87
49270
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49269
diff changeset
88 @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: 49269
diff changeset
89 def _p1_rev(index, rev, entry, hexfn):
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49269
diff changeset
90 return b"%d" % entry[constants.ENTRY_PARENT_1]
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49269
diff changeset
91
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49269
diff changeset
92
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
93 @debug_column(b"p1-nodeid", size=NODE_SIZE)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
94 def _p1_node(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
95 parent = entry[constants.ENTRY_PARENT_1]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
96 p_entry = index[parent]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
97 return hexfn(p_entry[constants.ENTRY_NODE_ID])
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
98
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
99
49271
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49270
diff changeset
100 @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: 49270
diff changeset
101 def _p2_rev(index, rev, entry, hexfn):
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49270
diff changeset
102 return b"%d" % entry[constants.ENTRY_PARENT_2]
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49270
diff changeset
103
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49270
diff changeset
104
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
105 @debug_column(b"p2-nodeid", size=NODE_SIZE)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
106 def _p2_node(index, rev, entry, hexfn):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
107 parent = entry[constants.ENTRY_PARENT_2]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
108 p_entry = index[parent]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
109 return hexfn(p_entry[constants.ENTRY_NODE_ID])
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
110
49265
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
111
49272
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49271
diff changeset
112 @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: 49271
diff changeset
113 def full_size(index, rev, entry, hexfn):
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49271
diff changeset
114 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: 49271
diff changeset
115
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49271
diff changeset
116
49273
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49272
diff changeset
117 @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: 49272
diff changeset
118 def delta_base(index, rev, entry, hexfn):
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49272
diff changeset
119 return b"%d" % entry[constants.ENTRY_DELTA_BASE]
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49272
diff changeset
120
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49272
diff changeset
121
49274
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49273
diff changeset
122 @debug_column(b"flags", size=2, verbose=True)
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49273
diff changeset
123 def flags(index, rev, entry, hexfn):
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49273
diff changeset
124 field = entry[constants.ENTRY_DATA_OFFSET]
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49273
diff changeset
125 field &= 0xFFFF
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49273
diff changeset
126 return b"%d" % field
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49273
diff changeset
127
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49273
diff changeset
128
49275
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49274
diff changeset
129 @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: 49274
diff changeset
130 def compression_mode(index, rev, entry, hexfn):
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49274
diff changeset
131 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: 49274
diff changeset
132
7a18f6fc7e0c debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49274
diff changeset
133
49276
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49275
diff changeset
134 @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: 49275
diff changeset
135 def data_offset(index, rev, entry, hexfn):
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49275
diff changeset
136 field = entry[constants.ENTRY_DATA_OFFSET]
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49275
diff changeset
137 field >>= 16
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49275
diff changeset
138 return b"%d" % field
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49275
diff changeset
139
7ba8adced391 debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49275
diff changeset
140
49277
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49276
diff changeset
141 @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: 49276
diff changeset
142 def data_chunk_size(index, rev, entry, hexfn):
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49276
diff changeset
143 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: 49276
diff changeset
144
4c145006b24a debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49276
diff changeset
145
49278
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
146 @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: 49277
diff changeset
147 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: 49277
diff changeset
148 compression = entry[constants.ENTRY_SIDEDATA_COMPRESSION_MODE]
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
149 if compression == constants.COMP_MODE_PLAIN:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
150 return b"plain"
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
151 elif compression == constants.COMP_MODE_DEFAULT:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
152 return b"default"
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
153 elif compression == constants.COMP_MODE_INLINE:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
154 return b"inline"
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
155 else:
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
156 return b"%d" % compression
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
157
27583efef74d debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49277
diff changeset
158
49279
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49278
diff changeset
159 @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: 49278
diff changeset
160 def sidedata_offset(index, rev, entry, hexfn):
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49278
diff changeset
161 return b"%d" % entry[constants.ENTRY_SIDEDATA_OFFSET]
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49278
diff changeset
162
e3a267a93711 debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49278
diff changeset
163
49280
30d2beab8163 debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49279
diff changeset
164 @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: 49279
diff changeset
165 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: 49279
diff changeset
166 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: 49279
diff changeset
167
30d2beab8163 debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49279
diff changeset
168
49265
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
169 def debug_index(
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
170 ui,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
171 repo,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
172 formatter,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
173 revlog,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
174 full_node,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
175 ):
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
176 """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
177 if full_node:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
178 hexfn = nodemod.hex
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
179 else:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
180 hexfn = nodemod.short
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 idlen = 12
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
183 for i in revlog:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
184 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
185 break
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
186
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
187 fm = formatter
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
188
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
189 header_pieces = []
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
190 for column in INDEX_ENTRY_DEBUG_COLUMN:
49269
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
191 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: 49268
diff changeset
192 continue
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
193 size = column.get_size(idlen)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
194 name = column.name
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
195 header_pieces.append(name.rjust(size))
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
196
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
197 fm.plain(b' '.join(header_pieces) + b'\n')
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
198
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
199 index = revlog.index
49265
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
200
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
201 for rev in revlog:
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
202 fm.startitem()
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
203 entry = index[rev]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
204 first = True
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
205 for column in INDEX_ENTRY_DEBUG_COLUMN:
49269
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49268
diff changeset
206 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: 49268
diff changeset
207 continue
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
208 if not first:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
209 fm.plain(b' ')
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
210 first = False
49265
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
211
49268
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
212 size = column.get_size(idlen)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
213 value = column.value_func(index, rev, entry, hexfn)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
214 display = b"%%%ds" % size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49267
diff changeset
215 fm.write(column.name, display, value)
49265
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
216 fm.plain(b'\n')
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
217
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
218 fm.end()