changeset 35347:bd326f3e0e14

debugformat: update label depending on value difference The new label highlight areas where the repo format differs from current config or default. This should help people spot area where a repository mismatch with the expected state.
author Boris Feld <boris.feld@octobus.net>
date Thu, 07 Dec 2017 16:12:32 +0100
parents cfb403b92f43
children 740d40ec15c3
files mercurial/color.py mercurial/debugcommands.py tests/test-upgrade-repo.t
diffstat 3 files changed, 38 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/color.py	Thu Dec 07 16:05:20 2017 +0100
+++ b/mercurial/color.py	Thu Dec 07 16:12:32 2017 +0100
@@ -102,6 +102,15 @@
     'changeset.secret': '',
     'diffstat.deleted': 'red',
     'diffstat.inserted': 'green',
+    'formatvariant.name.mismatchconfig': 'red',
+    'formatvariant.name.mismatchdefault': 'yellow',
+    'formatvariant.name.uptodate': 'green',
+    'formatvariant.repo.mismatchconfig': 'red',
+    'formatvariant.repo.mismatchdefault': 'yellow',
+    'formatvariant.repo.uptodate': 'green',
+    'formatvariant.config.special': 'yellow',
+    'formatvariant.config.default': 'green',
+    'formatvariant.default': '',
     'histedit.remaining': 'red bold',
     'ui.prompt': 'yellow',
     'log.changeset': 'yellow',
--- a/mercurial/debugcommands.py	Thu Dec 07 16:05:20 2017 +0100
+++ b/mercurial/debugcommands.py	Thu Dec 07 16:12:32 2017 +0100
@@ -891,12 +891,26 @@
         repovalue = fv.fromrepo(repo)
         configvalue = fv.fromconfig(repo)
 
+        if repovalue != configvalue:
+            namelabel = 'formatvariant.name.mismatchconfig'
+            repolabel = 'formatvariant.repo.mismatchconfig'
+        elif repovalue != fv.default:
+            namelabel = 'formatvariant.name.mismatchdefault'
+            repolabel = 'formatvariant.repo.mismatchdefault'
+        else:
+            namelabel = 'formatvariant.name.uptodate'
+            repolabel = 'formatvariant.repo.uptodate'
+
         fm.write('name', makeformatname(fv.name), fv.name,
-                 label='formatvariant.name')
+                 label=namelabel)
         fm.write('repo', ' %3s', formatvalue(repovalue),
-                 label='formatvariant.repo')
+                 label=repolabel)
+        if fv.default != configvalue:
+            configlabel = 'formatvariant.config.special'
+        else:
+            configlabel = 'formatvariant.config.default'
         fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue),
-                     label='formatvariant.config')
+                     label=configlabel)
         fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default),
                      label='formatvariant.default')
         fm.plain('\n')
--- a/tests/test-upgrade-repo.t	Thu Dec 07 16:05:20 2017 +0100
+++ b/tests/test-upgrade-repo.t	Thu Dec 07 16:12:32 2017 +0100
@@ -72,6 +72,12 @@
   dotencode:      yes    yes     yes
   generaldelta:   yes    yes     yes
   plain-cl-delta: yes    yes     yes
+  $ hg debugformat --verbose --config format.usegfncache=no --color=debug
+  format-variant repo config default
+  [formatvariant.name.uptodate|fncache:       ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
+  [formatvariant.name.uptodate|dotencode:     ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
+  [formatvariant.name.uptodate|generaldelta:  ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
+  [formatvariant.name.uptodate|plain-cl-delta:][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
   $ hg debugupgraderepo
   (no feature deficiencies found in existing repository)
   performing an upgrade with "--run" will make the following changes:
@@ -137,6 +143,12 @@
   dotencode:       no    yes     yes
   generaldelta:    no     no     yes
   plain-cl-delta: yes    yes     yes
+  $ hg debugformat --verbose --config format.usegeneraldelta=no --color=debug
+  format-variant repo config default
+  [formatvariant.name.mismatchconfig|fncache:       ][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|    yes][formatvariant.default|     yes]
+  [formatvariant.name.mismatchconfig|dotencode:     ][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|    yes][formatvariant.default|     yes]
+  [formatvariant.name.mismatchdefault|generaldelta:  ][formatvariant.repo.mismatchdefault|  no][formatvariant.config.special|     no][formatvariant.default|     yes]
+  [formatvariant.name.uptodate|plain-cl-delta:][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
   $ hg debugupgraderepo
   repository lacks features recommended by current config options: