Show More
@@ -0,0 +1,51 b'' | |||||
|
1 | # revlogutils/debug.py - utility used for revlog debuging | |||
|
2 | # | |||
|
3 | # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> | |||
|
4 | # Copyright 2022 Octobus <contact@octobus.net> | |||
|
5 | # | |||
|
6 | # This software may be used and distributed according to the terms of the | |||
|
7 | # GNU General Public License version 2 or any later version. | |||
|
8 | ||||
|
9 | from .. import ( | |||
|
10 | node as nodemod, | |||
|
11 | ) | |||
|
12 | ||||
|
13 | ||||
|
14 | def debug_index( | |||
|
15 | ui, | |||
|
16 | repo, | |||
|
17 | formatter, | |||
|
18 | revlog, | |||
|
19 | full_node, | |||
|
20 | ): | |||
|
21 | """display index data for a revlog""" | |||
|
22 | if full_node: | |||
|
23 | hexfn = nodemod.hex | |||
|
24 | else: | |||
|
25 | hexfn = nodemod.short | |||
|
26 | ||||
|
27 | idlen = 12 | |||
|
28 | for i in revlog: | |||
|
29 | idlen = len(hexfn(revlog.node(i))) | |||
|
30 | break | |||
|
31 | ||||
|
32 | fm = formatter | |||
|
33 | ||||
|
34 | fm.plain( | |||
|
35 | b' rev linkrev %s %s p2\n' | |||
|
36 | % (b'nodeid'.ljust(idlen), b'p1'.ljust(idlen)) | |||
|
37 | ) | |||
|
38 | ||||
|
39 | for rev in revlog: | |||
|
40 | node = revlog.node(rev) | |||
|
41 | parents = revlog.parents(node) | |||
|
42 | ||||
|
43 | fm.startitem() | |||
|
44 | fm.write(b'rev', b'%6d ', rev) | |||
|
45 | fm.write(b'linkrev', b'%7d ', revlog.linkrev(rev)) | |||
|
46 | fm.write(b'node', b'%s ', hexfn(node)) | |||
|
47 | fm.write(b'p1', b'%s ', hexfn(parents[0])) | |||
|
48 | fm.write(b'p2', b'%s', hexfn(parents[1])) | |||
|
49 | fm.plain(b'\n') | |||
|
50 | ||||
|
51 | fm.end() |
@@ -105,6 +105,7 b' from .utils import (' | |||||
105 |
|
105 | |||
106 | from .revlogutils import ( |
|
106 | from .revlogutils import ( | |
107 | constants as revlog_constants, |
|
107 | constants as revlog_constants, | |
|
108 | debug as revlog_debug, | |||
108 | deltas as deltautil, |
|
109 | deltas as deltautil, | |
109 | nodemap, |
|
110 | nodemap, | |
110 | rewrite, |
|
111 | rewrite, | |
@@ -1874,36 +1875,16 b' def debugindex(ui, repo, file_=None, **o' | |||||
1874 | opts = pycompat.byteskwargs(opts) |
|
1875 | opts = pycompat.byteskwargs(opts) | |
1875 | store = cmdutil.openstorage(repo, b'debugindex', file_, opts) |
|
1876 | store = cmdutil.openstorage(repo, b'debugindex', file_, opts) | |
1876 |
|
1877 | |||
1877 | if ui.debugflag: |
|
|||
1878 | shortfn = hex |
|
|||
1879 | else: |
|
|||
1880 | shortfn = short |
|
|||
1881 |
|
||||
1882 | idlen = 12 |
|
|||
1883 | for i in store: |
|
|||
1884 | idlen = len(shortfn(store.node(i))) |
|
|||
1885 | break |
|
|||
1886 |
|
||||
1887 | fm = ui.formatter(b'debugindex', opts) |
|
1878 | fm = ui.formatter(b'debugindex', opts) | |
1888 | fm.plain( |
|
1879 | ||
1889 | b' rev linkrev %s %s p2\n' |
|
1880 | return revlog_debug.debug_index( | |
1890 | % (b'nodeid'.ljust(idlen), b'p1'.ljust(idlen)) |
|
1881 | ui, | |
|
1882 | repo, | |||
|
1883 | formatter=fm, | |||
|
1884 | revlog=store, | |||
|
1885 | full_node=ui.debugflag, | |||
1891 | ) |
|
1886 | ) | |
1892 |
|
1887 | |||
1893 | for rev in store: |
|
|||
1894 | node = store.node(rev) |
|
|||
1895 | parents = store.parents(node) |
|
|||
1896 |
|
||||
1897 | fm.startitem() |
|
|||
1898 | fm.write(b'rev', b'%6d ', rev) |
|
|||
1899 | fm.write(b'linkrev', b'%7d ', store.linkrev(rev)) |
|
|||
1900 | fm.write(b'node', b'%s ', shortfn(node)) |
|
|||
1901 | fm.write(b'p1', b'%s ', shortfn(parents[0])) |
|
|||
1902 | fm.write(b'p2', b'%s', shortfn(parents[1])) |
|
|||
1903 | fm.plain(b'\n') |
|
|||
1904 |
|
||||
1905 | fm.end() |
|
|||
1906 |
|
||||
1907 |
|
1888 | |||
1908 | @command( |
|
1889 | @command( | |
1909 | b'debugindexdot', |
|
1890 | b'debugindexdot', |
General Comments 0
You need to be logged in to leave comments.
Login now