Patchwork [3,of,6] debugformat: add data about the config when verbose

login
register
mail settings
Submitter Boris Feld
Date Dec. 8, 2017, 10:58 a.m.
Message ID <0c9fa09bab4cdc2af7d5.1512730682@FB>
Download mbox | patch
Permalink /patch/26092/
State Accepted
Headers show

Comments

Boris Feld - Dec. 8, 2017, 10:58 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1512659120 -3600
#      Thu Dec 07 16:05:20 2017 +0100
# Node ID 0c9fa09bab4cdc2af7d5541d31de2aba694e9002
# Parent  98baa863b15b6168076dc8d1ae87f22f7cac6746
# EXP-Topic upgrade
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0c9fa09bab4c
debugformat: add data about the config when verbose

In verbose mode, the command also displays the current configuration choice
for the variant and the global Mercurial default for it.

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -863,7 +863,10 @@  def debugfileset(ui, repo, expr, **opts)
          [] + cmdutil.formatteropts,
         _(''))
 def debugformat(ui, repo, **opts):
-    """display format information about the current repository"""
+    """display format information about the current repository
+
+    Use --verbose to get extra information about current config value and
+    Mercurial default."""
     maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant)
     maxvariantlength = max(len('format-variant'), maxvariantlength)
 
@@ -880,15 +883,22 @@  def debugformat(ui, repo, **opts):
     fm.plain('format-variant')
     fm.plain(' ' * (maxvariantlength - len('format-variant')))
     fm.plain(' repo')
+    if ui.verbose:
+        fm.plain(' config default')
     fm.plain('\n')
     fm.startitem()
     for fv in upgrade.allformatvariant:
         repovalue = fv.fromrepo(repo)
+        configvalue = fv.fromconfig(repo)
 
         fm.write('name', makeformatname(fv.name), fv.name,
                  label='formatvariant.name')
         fm.write('repo', ' %3s', formatvalue(repovalue),
                  label='formatvariant.repo')
+        fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue),
+                     label='formatvariant.config')
+        fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default),
+                     label='formatvariant.default')
         fm.plain('\n')
 
 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -60,6 +60,18 @@  An upgrade of a repository created with 
   dotencode:      yes
   generaldelta:   yes
   plain-cl-delta: yes
+  $ hg debugformat --verbose
+  format-variant repo config default
+  fncache:        yes    yes     yes
+  dotencode:      yes    yes     yes
+  generaldelta:   yes    yes     yes
+  plain-cl-delta: yes    yes     yes
+  $ hg debugformat --verbose --config format.usegfncache=no
+  format-variant repo config default
+  fncache:        yes    yes     yes
+  dotencode:      yes    yes     yes
+  generaldelta:   yes    yes     yes
+  plain-cl-delta: yes    yes     yes
   $ hg debugupgraderepo
   (no feature deficiencies found in existing repository)
   performing an upgrade with "--run" will make the following changes:
@@ -113,6 +125,18 @@  Various sub-optimal detections work
   dotencode:       no
   generaldelta:    no
   plain-cl-delta: yes
+  $ hg debugformat --verbose
+  format-variant repo config default
+  fncache:         no    yes     yes
+  dotencode:       no    yes     yes
+  generaldelta:    no    yes     yes
+  plain-cl-delta: yes    yes     yes
+  $ hg debugformat --verbose --config format.usegeneraldelta=no
+  format-variant repo config default
+  fncache:         no    yes     yes
+  dotencode:       no    yes     yes
+  generaldelta:    no     no     yes
+  plain-cl-delta: yes    yes     yes
   $ hg debugupgraderepo
   repository lacks features recommended by current config options: