debugformat: add a 'debugformat' command
authorBoris Feld <boris.feld@octobus.net>
Thu, 07 Dec 2017 16:19:46 +0100
changeset 35336 c3e4f196b6e0
parent 35335 0181f99819d2
child 35337 cfb403b92f43
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.
mercurial/debugcommands.py
tests/test-completion.t
tests/test-help.t
tests/test-upgrade-repo.t
--- 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"""
--- a/tests/test-completion.t	Thu Dec 07 15:55:59 2017 +0100
+++ b/tests/test-completion.t	Thu Dec 07 16:19:46 2017 +0100
@@ -87,6 +87,7 @@
   debugdiscovery
   debugextensions
   debugfileset
+  debugformat
   debugfsinfo
   debuggetbundle
   debugignore
@@ -264,6 +265,7 @@
   debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
   debugextensions: template
   debugfileset: rev
+  debugformat: template
   debugfsinfo: 
   debuggetbundle: head, common, type
   debugignore: 
--- a/tests/test-help.t	Thu Dec 07 15:55:59 2017 +0100
+++ b/tests/test-help.t	Thu Dec 07 16:19:46 2017 +0100
@@ -922,6 +922,7 @@
    debugextensions
                  show information about active extensions
    debugfileset  parse and apply a fileset specification
+   debugformat   display format information about the current repository
    debugfsinfo   show information detected about current filesystem
    debuggetbundle
                  retrieves a bundle from a repo
--- a/tests/test-upgrade-repo.t	Thu Dec 07 15:55:59 2017 +0100
+++ b/tests/test-upgrade-repo.t	Thu Dec 07 16:19:46 2017 +0100
@@ -54,6 +54,12 @@
 
   $ hg init empty
   $ cd empty
+  $ hg debugformat
+  format-variant repo
+  fncache:        yes
+  dotencode:      yes
+  generaldelta:   yes
+  plain-cl-delta: yes
   $ hg debugupgraderepo
   (no feature deficiencies found in existing repository)
   performing an upgrade with "--run" will make the following changes:
@@ -101,6 +107,12 @@
   > store
   > EOF
 
+  $ hg debugformat
+  format-variant repo
+  fncache:         no
+  dotencode:       no
+  generaldelta:    no
+  plain-cl-delta: yes
   $ hg debugupgraderepo
   repository lacks features recommended by current config options: