annotate mercurial/revlogutils/debug.py @ 49259:fbb2477298a6

debugindex: add a `flags` column
author Pierre-Yves DAVID <pierre-yves.david@octobus.net>
date Wed, 01 Jun 2022 01:33:25 +0200
parents f6ef18be36e1
children 7a18f6fc7e0c
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
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
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
13 from . import (
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
14 constants,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
15 )
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
16
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
17 INDEX_ENTRY_DEBUG_COLUMN = []
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
18
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
19 NODE_SIZE = object()
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
20
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 class _column_base:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
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: 49252
diff changeset
24
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
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: 49253
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: 49253
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: 49253
diff changeset
28 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
29 """
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 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
32 self.name = name
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
33 self.value_func = value_func
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
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: 49252
diff changeset
35 if size is None:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
36 size = 8 # arbitrary default
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
37 size = max(len(name), size)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
38 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
39 self.verbose_only = verbose
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
40
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
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: 49252
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: 49252
diff changeset
43 return node_size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
44 else:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
45 return self._size
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
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
48 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
49 """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
50
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
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: 49252
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: 49252
diff changeset
53 """
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
54
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
55 def register(func):
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
56 entry = _column_base(
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
57 name=name,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
58 value_func=func,
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
59 size=size,
49254
69983adfed06 debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49253
diff changeset
60 verbose=verbose,
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
61 )
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
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: 49252
diff changeset
63 return entry
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
64
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
65 return register
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
66
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 @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
69 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
70 return b"%d" % rev
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
71
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 @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
74 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
75 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
76
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 @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
79 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
80 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
81
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
82
49255
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49254
diff changeset
83 @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
84 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
85 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
86
251650844331 debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49254
diff changeset
87
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
88 @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
89 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
90 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
91 p_entry = index[parent]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
92 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
93
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
94
49256
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49255
diff changeset
95 @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
96 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
97 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
98
d910ca4e995b debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49255
diff changeset
99
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
100 @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
101 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
102 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
103 p_entry = index[parent]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
104 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
105
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
106
49257
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49256
diff changeset
107 @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
108 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
109 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
110
b0238fc496af debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49256
diff changeset
111
49258
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49257
diff changeset
112 @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
113 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
114 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
115
f6ef18be36e1 debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49257
diff changeset
116
49259
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
117 @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
118 def flags(index, rev, entry, hexfn):
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
119 field = entry[constants.ENTRY_DATA_OFFSET]
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
120 field &= 0xFFFF
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
121 return b"%d" % field
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
122
fbb2477298a6 debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49258
diff changeset
123
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
124 def debug_index(
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
125 ui,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
126 repo,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
127 formatter,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
128 revlog,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
129 full_node,
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
130 ):
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
131 """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
132 if full_node:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
133 hexfn = nodemod.hex
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
134 else:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
135 hexfn = nodemod.short
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
136
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
137 idlen = 12
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
138 for i in revlog:
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
139 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
140 break
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
141
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
142 fm = formatter
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
143
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
144 header_pieces = []
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
145 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
146 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
147 continue
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
148 size = column.get_size(idlen)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
149 name = column.name
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
150 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
151
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
152 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
153
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
154 index = revlog.index
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
155
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
156 for rev in revlog:
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
157 fm.startitem()
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
158 entry = index[rev]
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
159 first = True
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
160 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
161 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
162 continue
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
163 if not first:
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
164 fm.plain(b' ')
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
165 first = False
49250
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
166
49253
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
167 size = column.get_size(idlen)
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
168 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
169 display = b"%%%ds" % size
a321304269cf debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49252
diff changeset
170 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
171 fm.plain(b'\n')
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
172
61cf3d39fd9e debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
173 fm.end()