comparison mercurial/debugcommands.py @ 49265:61cf3d39fd9e

debugindex: move the logic into its own module Adding more information will significantly increase the amount of code. So we move the code into its own module before making it more complex.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 30 May 2022 23:24:14 +0200
parents db19f6be0442
children a321304269cf
comparison
equal deleted inserted replaced
49264:db19f6be0442 49265:61cf3d39fd9e
103 urlutil, 103 urlutil,
104 ) 104 )
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,
111 sidedata, 112 sidedata,
112 ) 113 )
1872 def debugindex(ui, repo, file_=None, **opts): 1873 def debugindex(ui, repo, file_=None, **opts):
1873 """dump index data for a revlog""" 1874 """dump index data for a revlog"""
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
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 1887
1907 1888
1908 @command( 1889 @command(
1909 b'debugindexdot', 1890 b'debugindexdot',
1910 cmdutil.debugrevlogopts, 1891 cmdutil.debugrevlogopts,