Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 35345:c3e4f196b6e0
debugformat: add a 'debugformat' command
The command displays basic data about all format variants registered for repo
upgrades. This gives a quick way to peek into a repository format.
The 'fm.write()' calls are very independent because more data will be added in
later changeset. Having more separate call make the later patch clearer.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 07 Dec 2017 16:19:46 +0100 |
parents | f77121b6bf1b |
children | cfb403b92f43 |
comparison
equal
deleted
inserted
replaced
35344:0181f99819d2 | 35345:c3e4f196b6e0 |
---|---|
857 ui.note(fileset.prettyformat(tree), "\n") | 857 ui.note(fileset.prettyformat(tree), "\n") |
858 | 858 |
859 for f in ctx.getfileset(expr): | 859 for f in ctx.getfileset(expr): |
860 ui.write("%s\n" % f) | 860 ui.write("%s\n" % f) |
861 | 861 |
862 @command('debugformat', | |
863 [] + cmdutil.formatteropts, | |
864 _('')) | |
865 def debugformat(ui, repo, **opts): | |
866 """display format information about the current repository""" | |
867 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) | |
868 maxvariantlength = max(len('format-variant'), maxvariantlength) | |
869 | |
870 def makeformatname(name): | |
871 return '%s:' + (' ' * (maxvariantlength - len(name))) | |
872 | |
873 def formatvalue(value): | |
874 if value: | |
875 return 'yes' | |
876 else: | |
877 return 'no' | |
878 | |
879 fm = ui.formatter('debugformat', opts) | |
880 fm.plain('format-variant') | |
881 fm.plain(' ' * (maxvariantlength - len('format-variant'))) | |
882 fm.plain(' repo') | |
883 fm.plain('\n') | |
884 fm.startitem() | |
885 for fv in upgrade.allformatvariant: | |
886 repovalue = fv.fromrepo(repo) | |
887 | |
888 fm.write('name', makeformatname(fv.name), fv.name, | |
889 label='formatvariant.name') | |
890 fm.write('repo', ' %3s', formatvalue(repovalue), | |
891 label='formatvariant.repo') | |
892 fm.plain('\n') | |
893 | |
862 @command('debugfsinfo', [], _('[PATH]'), norepo=True) | 894 @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
863 def debugfsinfo(ui, path="."): | 895 def debugfsinfo(ui, path="."): |
864 """show information detected about current filesystem""" | 896 """show information detected about current filesystem""" |
865 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) | 897 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) |
866 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) | 898 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) |