Patchwork D10325: revlog-compression: fix computation of engine availability

login
register
mail settings
Submitter phabricator
Date April 7, 2021, 11:55 a.m.
Message ID <differential-rev-PHID-DREV-hgjifcuufeq4s54udapi-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48642/
State Superseded
Headers show

Comments

phabricator - April 7, 2021, 11:55 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We don't just need the engine to be define, we need it to be available and able
  to do be used for revlog compression. Without this change, `zstd` could be
  selected as a viable option for repository creation on platform where it is not
  available.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10325

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/upgrade_utils/actions.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/upgrade_utils/actions.py b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -428,7 +428,9 @@ 
         # return the first valid value as the selection code would do
         for comp in compengines:
             if comp in util.compengines:
-                return comp
+                e = util.compengines[comp]
+                if e.available() and e.revlogheader():
+                    return comp
 
         # no valide compression found lets display it all for clarity
         return b','.join(compengines)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3470,7 +3470,9 @@ 
     compengines = ui.configlist(b'format', b'revlog-compression')
     for compengine in compengines:
         if compengine in util.compengines:
-            break
+            engine = util.compengines[compengine]
+            if engine.available() and engine.revlogheader():
+                break
     else:
         raise error.Abort(
             _(