Show More
@@ -0,0 +1,51 | |||
|
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 from .utils import ( | |||
|
105 | 105 | |
|
106 | 106 | from .revlogutils import ( |
|
107 | 107 | constants as revlog_constants, |
|
108 | debug as revlog_debug, | |
|
108 | 109 | deltas as deltautil, |
|
109 | 110 | nodemap, |
|
110 | 111 | rewrite, |
@@ -1874,35 +1875,15 def debugindex(ui, repo, file_=None, **o | |||
|
1874 | 1875 | opts = pycompat.byteskwargs(opts) |
|
1875 | 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 | 1878 | fm = ui.formatter(b'debugindex', opts) |
|
1888 | fm.plain( | |
|
1889 | b' rev linkrev %s %s p2\n' | |
|
1890 | % (b'nodeid'.ljust(idlen), b'p1'.ljust(idlen)) | |
|
1891 | ) | |
|
1892 | ||
|
1893 |
|
|
|
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() | |
|
1879 | ||
|
1880 | return revlog_debug.debug_index( | |
|
1881 | ui, | |
|
1882 | repo, | |
|
1883 | formatter=fm, | |
|
1884 | revlog=store, | |
|
1885 | full_node=ui.debugflag, | |
|
1886 | ) | |
|
1906 | 1887 | |
|
1907 | 1888 | |
|
1908 | 1889 | @command( |
General Comments 0
You need to be logged in to leave comments.
Login now