Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Thu Dec 07 15:55:59 2017 +0100 +++ b/mercurial/debugcommands.py Thu Dec 07 16:19:46 2017 +0100 @@ -859,6 +859,38 @@ for f in ctx.getfileset(expr): ui.write("%s\n" % f) +@command('debugformat', + [] + cmdutil.formatteropts, + _('')) +def debugformat(ui, repo, **opts): + """display format information about the current repository""" + maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) + maxvariantlength = max(len('format-variant'), maxvariantlength) + + def makeformatname(name): + return '%s:' + (' ' * (maxvariantlength - len(name))) + + def formatvalue(value): + if value: + return 'yes' + else: + return 'no' + + fm = ui.formatter('debugformat', opts) + fm.plain('format-variant') + fm.plain(' ' * (maxvariantlength - len('format-variant'))) + fm.plain(' repo') + fm.plain('\n') + fm.startitem() + for fv in upgrade.allformatvariant: + repovalue = fv.fromrepo(repo) + + fm.write('name', makeformatname(fv.name), fv.name, + label='formatvariant.name') + fm.write('repo', ' %3s', formatvalue(repovalue), + label='formatvariant.repo') + fm.plain('\n') + @command('debugfsinfo', [], _('[PATH]'), norepo=True) def debugfsinfo(ui, path="."): """show information detected about current filesystem"""