[PATCH 5 of 8 "] compression: display compression level in debugformat

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Mar 31 11:36:21 EDT 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1553725731 -3600
#      Wed Mar 27 23:28:51 2019 +0100
# Node ID 28701199a78bdbab36aa422be0b4681941433823
# Parent  bcc4ba4c53b44dc6013b89f8c85b0f1967dfaebb
# EXP-Topic zstd-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 28701199a78b
compression: display compression level in debugformat

Now that we have options to control the compression level, we teach `hg
debugformat` about them. This is a useful information when comparing
repositories.

Note that we have no trace of the compression level used to store existing
deltas. Actually, it would even varies from one delta to another. So we display
the currently set value.

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -334,6 +334,39 @@ class compressionengine(formatvariant):
     def fromconfig(cls, repo):
         return repo.ui.config('experimental', 'format.compression')
 
+ at registerformatvariant
+class compressionlevel(formatvariant):
+    name = 'compression-level'
+    default = 'default'
+
+    description = _('compression level')
+
+    upgrademessage = _('revlog content will be recompressed')
+
+    @classmethod
+    def fromrepo(cls, repo):
+        comp = compressionengine.fromrepo(repo)
+        level = None
+        if comp == 'zlib':
+            level = repo.ui.configint('storage', 'revlog.zlib.level')
+        elif comp == 'zstd':
+            level = repo.ui.configint('storage', 'revlog.zstd.level')
+        if level is None:
+            return 'default'
+        return str(level)
+
+    @classmethod
+    def fromconfig(cls, repo):
+        comp = compressionengine.fromconfig(repo)
+        level = None
+        if comp == 'zlib':
+            level = repo.ui.configint('storage', 'revlog.zlib.level')
+        elif comp == 'zstd':
+            level = repo.ui.configint('storage', 'revlog.zstd.level')
+        if level is None:
+            return 'default'
+        return str(level)
+
 def finddeficiencies(repo):
     """returns a list of deficiencies that the repo suffer from"""
     deficiencies = []
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
@@ -52,37 +52,41 @@ An upgrade of a repository created with 
   $ hg init empty
   $ cd empty
   $ hg debugformat
-  format-variant repo
-  fncache:        yes
-  dotencode:      yes
-  generaldelta:   yes
-  sparserevlog:   yes
-  plain-cl-delta: yes
-  compression:    zlib
+  format-variant    repo
+  fncache:           yes
+  dotencode:         yes
+  generaldelta:      yes
+  sparserevlog:      yes
+  plain-cl-delta:    yes
+  compression:       zlib
+  compression-level: default
   $ hg debugformat --verbose
-  format-variant repo config default
-  fncache:        yes    yes     yes
-  dotencode:      yes    yes     yes
-  generaldelta:   yes    yes     yes
-  sparserevlog:   yes    yes     yes
-  plain-cl-delta: yes    yes     yes
-  compression:    zlib   zlib    zlib
+  format-variant    repo config default
+  fncache:           yes    yes     yes
+  dotencode:         yes    yes     yes
+  generaldelta:      yes    yes     yes
+  sparserevlog:      yes    yes     yes
+  plain-cl-delta:    yes    yes     yes
+  compression:       zlib   zlib    zlib
+  compression-level: default default default
   $ hg debugformat --verbose --config format.usefncache=no
-  format-variant repo config default
-  fncache:        yes     no     yes
-  dotencode:      yes     no     yes
-  generaldelta:   yes    yes     yes
-  sparserevlog:   yes    yes     yes
-  plain-cl-delta: yes    yes     yes
-  compression:    zlib   zlib    zlib
+  format-variant    repo config default
+  fncache:           yes     no     yes
+  dotencode:         yes     no     yes
+  generaldelta:      yes    yes     yes
+  sparserevlog:      yes    yes     yes
+  plain-cl-delta:    yes    yes     yes
+  compression:       zlib   zlib    zlib
+  compression-level: default default default
   $ hg debugformat --verbose --config format.usefncache=no --color=debug
-  format-variant repo config default
-  [formatvariant.name.mismatchconfig|fncache:       ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special|     no][formatvariant.default|     yes]
-  [formatvariant.name.mismatchconfig|dotencode:     ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special|     no][formatvariant.default|     yes]
-  [formatvariant.name.uptodate|generaldelta:  ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
-  [formatvariant.name.uptodate|sparserevlog:  ][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]
-  [formatvariant.name.uptodate|compression:   ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   zlib][formatvariant.default|    zlib]
+  format-variant    repo config default
+  [formatvariant.name.mismatchconfig|fncache:          ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special|     no][formatvariant.default|     yes]
+  [formatvariant.name.mismatchconfig|dotencode:        ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special|     no][formatvariant.default|     yes]
+  [formatvariant.name.uptodate|generaldelta:     ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
+  [formatvariant.name.uptodate|sparserevlog:     ][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]
+  [formatvariant.name.uptodate|compression:      ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   zlib][formatvariant.default|    zlib]
+  [formatvariant.name.uptodate|compression-level:][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
   $ hg debugformat -Tjson
   [
    {
@@ -120,6 +124,12 @@ An upgrade of a repository created with 
     "default": "zlib",
     "name": "compression",
     "repo": "zlib"
+   },
+   {
+    "config": "default",
+    "default": "default",
+    "name": "compression-level",
+    "repo": "default"
    }
   ]
   $ hg debugupgraderepo
@@ -207,37 +217,41 @@ Various sub-optimal detections work
   > EOF
 
   $ hg debugformat
-  format-variant repo
-  fncache:         no
-  dotencode:       no
-  generaldelta:    no
-  sparserevlog:    no
-  plain-cl-delta: yes
-  compression:    zlib
+  format-variant    repo
+  fncache:            no
+  dotencode:          no
+  generaldelta:       no
+  sparserevlog:       no
+  plain-cl-delta:    yes
+  compression:       zlib
+  compression-level: default
   $ hg debugformat --verbose
-  format-variant repo config default
-  fncache:         no    yes     yes
-  dotencode:       no    yes     yes
-  generaldelta:    no    yes     yes
-  sparserevlog:    no    yes     yes
-  plain-cl-delta: yes    yes     yes
-  compression:    zlib   zlib    zlib
+  format-variant    repo config default
+  fncache:            no    yes     yes
+  dotencode:          no    yes     yes
+  generaldelta:       no    yes     yes
+  sparserevlog:       no    yes     yes
+  plain-cl-delta:    yes    yes     yes
+  compression:       zlib   zlib    zlib
+  compression-level: default default default
   $ hg debugformat --verbose --config format.usegeneraldelta=no
-  format-variant repo config default
-  fncache:         no    yes     yes
-  dotencode:       no    yes     yes
-  generaldelta:    no     no     yes
-  sparserevlog:    no     no     yes
-  plain-cl-delta: yes    yes     yes
-  compression:    zlib   zlib    zlib
+  format-variant    repo config default
+  fncache:            no    yes     yes
+  dotencode:          no    yes     yes
+  generaldelta:       no     no     yes
+  sparserevlog:       no     no     yes
+  plain-cl-delta:    yes    yes     yes
+  compression:       zlib   zlib    zlib
+  compression-level: default default default
   $ 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.mismatchdefault|sparserevlog:  ][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]
-  [formatvariant.name.uptodate|compression:   ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   zlib][formatvariant.default|    zlib]
+  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.mismatchdefault|sparserevlog:     ][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]
+  [formatvariant.name.uptodate|compression:      ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   zlib][formatvariant.default|    zlib]
+  [formatvariant.name.uptodate|compression-level:][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
   $ hg debugupgraderepo
   repository lacks features recommended by current config options:
   


More information about the Mercurial-devel mailing list