author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Mon, 30 May 2022 23:24:14 +0200 | |
changeset 49265 | 61cf3d39fd9e |
child 49266 | ccd76e292be5 |
permissions | -rw-r--r-- |
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 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
13 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 |
def debug_index( |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
15 |
ui, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 |
repo, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 |
formatter, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 |
revlog, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 |
full_node, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 |
): |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 |
"""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
|
22 |
if full_node: |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 |
hexfn = nodemod.hex |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
24 |
else: |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
25 |
hexfn = nodemod.short |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
26 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
27 |
idlen = 12 |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
28 |
for i in revlog: |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
29 |
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
|
30 |
break |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
31 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
32 |
fm = formatter |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
33 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
34 |
fm.plain( |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
35 |
b' rev linkrev %s %s p2\n' |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
36 |
% (b'nodeid'.ljust(idlen), b'p1'.ljust(idlen)) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
37 |
) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
38 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
39 |
for rev in revlog: |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
40 |
node = revlog.node(rev) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
41 |
parents = revlog.parents(node) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
42 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
43 |
fm.startitem() |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
44 |
fm.write(b'rev', b'%6d ', rev) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
45 |
fm.write(b'linkrev', b'%7d ', revlog.linkrev(rev)) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
46 |
fm.write(b'node', b'%s ', hexfn(node)) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
47 |
fm.write(b'p1', b'%s ', hexfn(parents[0])) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
48 |
fm.write(b'p2', b'%s', hexfn(parents[1])) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
49 |
fm.plain(b'\n') |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
50 |
|
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
51 |
fm.end() |