# HG changeset patch # User Boris Feld # Date 2017-12-07 15:50:48 # Node ID ead01b74be04ffeb826055015d6f9ac9c256c419 # Parent 740d40ec15c37215d18edb88dbbd5e2e14fc26ce upgrade: register compression as a format variants Compression is a promising vector for speedup, let us make it easier to check the compression used and upgrade existing repository. diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -284,6 +284,28 @@ class removecldeltachain(formatvariant): def fromconfig(repo): return True +@registerformatvariant +class compressionengine(formatvariant): + name = 'compression' + default = 'zlib' + + description = _('Compresion algorithm used to compress data. ' + 'Some engine are faster than other') + + upgrademessage = _('revlog content will be recompressed with the new ' + 'algorithm.') + + @classmethod + def fromrepo(cls, repo): + for req in repo.requirements: + if req.startswith('exp-compression-'): + return req.split('-', 2)[2] + return 'zlib' + + @classmethod + def fromconfig(cls, repo): + return repo.ui.config('experimental', 'format.compression') + 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 @@ -60,24 +60,28 @@ An upgrade of a repository created with dotencode: yes generaldelta: yes plain-cl-delta: yes + compression: zlib $ 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 + compression: zlib zlib zlib $ 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 + compression: zlib zlib zlib $ 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] + [formatvariant.name.uptodate|compression: ][formatvariant.repo.uptodate| zlib][formatvariant.config.default| zlib][formatvariant.default| zlib] $ hg debugupgraderepo (no feature deficiencies found in existing repository) performing an upgrade with "--run" will make the following changes: @@ -131,24 +135,28 @@ Various sub-optimal detections work dotencode: no generaldelta: no plain-cl-delta: yes + compression: zlib $ 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 + compression: zlib zlib zlib $ 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 + compression: zlib zlib zlib $ 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] + [formatvariant.name.uptodate|compression: ][formatvariant.repo.uptodate| zlib][formatvariant.config.default| zlib][formatvariant.default| zlib] $ hg debugupgraderepo repository lacks features recommended by current config options: