Mercurial > hg
annotate mercurial/revlogutils/debug.py @ 49432:b4535c88a05b
phase-shelve: also capture the state of shelve prior to unshelve
author | Jason R. Coombs <jaraco@jaraco.com> |
---|---|
date | Wed, 17 Aug 2022 12:03:55 -0400 |
parents | da3e37ecacde |
children | 7c0a383849a8 |
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 |
49266
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
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:
49265
diff
changeset
|
74 def rank(index, rev, entry, hexfn): |
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
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:
49265
diff
changeset
|
76 |
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
diff
changeset
|
77 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
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:
49252
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:
49252
diff
changeset
|
81 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
82 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
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:
49252
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:
49252
diff
changeset
|
86 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
87 |
49255
251650844331
debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49254
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:
49254
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:
49254
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:
49254
diff
changeset
|
91 |
251650844331
debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49254
diff
changeset
|
92 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
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:
49252
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:
49252
diff
changeset
|
96 p_entry = index[parent] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
diff
changeset
|
98 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
99 |
49256
d910ca4e995b
debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49255
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:
49255
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:
49255
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:
49255
diff
changeset
|
103 |
d910ca4e995b
debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49255
diff
changeset
|
104 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
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:
49252
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:
49252
diff
changeset
|
108 p_entry = index[parent] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
diff
changeset
|
110 |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
111 |
49257
b0238fc496af
debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49256
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:
49256
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:
49256
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:
49256
diff
changeset
|
115 |
b0238fc496af
debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49256
diff
changeset
|
116 |
49258
f6ef18be36e1
debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49257
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:
49257
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:
49257
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:
49257
diff
changeset
|
120 |
f6ef18be36e1
debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49257
diff
changeset
|
121 |
49259
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
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:
49258
diff
changeset
|
123 def flags(index, rev, entry, hexfn): |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
124 field = entry[constants.ENTRY_DATA_OFFSET] |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
125 field &= 0xFFFF |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
126 return b"%d" % field |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
127 |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
128 |
49260
7a18f6fc7e0c
debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49259
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:
49259
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:
49259
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:
49259
diff
changeset
|
132 |
7a18f6fc7e0c
debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49259
diff
changeset
|
133 |
49261
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
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:
49260
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:
49260
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:
49260
diff
changeset
|
137 field >>= 16 |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
138 return b"%d" % field |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
139 |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
140 |
49262
4c145006b24a
debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49261
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:
49261
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:
49261
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:
49261
diff
changeset
|
144 |
4c145006b24a
debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49261
diff
changeset
|
145 |
49263
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
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:
49262
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:
49262
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:
49262
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:
49262
diff
changeset
|
150 return b"plain" |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
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:
49262
diff
changeset
|
152 return b"default" |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
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:
49262
diff
changeset
|
154 return b"inline" |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
155 else: |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
156 return b"%d" % compression |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
157 |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
158 |
49264
e3a267a93711
debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49263
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:
49263
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:
49263
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:
49263
diff
changeset
|
162 |
e3a267a93711
debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49263
diff
changeset
|
163 |
49265
30d2beab8163
debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49264
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:
49264
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:
49264
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:
49264
diff
changeset
|
167 |
30d2beab8163
debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49264
diff
changeset
|
168 |
49250
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 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
189 header_pieces = [] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
190 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
|
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:
49253
diff
changeset
|
192 continue |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
193 size = column.get_size(idlen) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
194 name = column.name |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
diff
changeset
|
196 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
diff
changeset
|
198 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
199 index = revlog.index |
49250
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: |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
202 fm.startitem() |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
203 entry = index[rev] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
204 first = True |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
205 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
|
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:
49253
diff
changeset
|
207 continue |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
208 if not first: |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
209 fm.plain(b' ') |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
210 first = False |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
211 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
212 size = column.get_size(idlen) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
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:
49252
diff
changeset
|
214 display = b"%%%ds" % size |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
215 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
|
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() |