Patchwork [4,of,6] debugformat: update label depending on value difference

login
register
mail settings
Submitter Boris Feld
Date Dec. 8, 2017, 10:58 a.m.
Message ID <88e1cddecf068bac5850.1512730683@FB>
Download mbox | patch
Permalink /patch/26095/
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 1512659552 -3600
#      Thu Dec 07 16:12:32 2017 +0100
# Node ID 88e1cddecf068bac5850a0beea0354ffa29f78c3
# Parent  0c9fa09bab4cdc2af7d5541d31de2aba694e9002
# EXP-Topic upgrade
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 88e1cddecf06
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.

Patch

diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -102,6 +102,15 @@  except ImportError:
     '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',
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -891,12 +891,26 @@  def debugformat(ui, repo, **opts):
         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')
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
@@ -72,6 +72,12 @@  An upgrade of a repository created with 
   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 @@  Various sub-optimal detections work
   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: