# HG changeset patch # User Gregory Szorc # Date 2016-11-11 07:03:48 # Node ID 64d7275445d0706c6cdbe2420c4014899aa33945 # Parent 788ea4ac438843f3e437769499c17af1383bc942 util: expose an "available" API on compression engines When the zstd compression engine is introduced, it won't work in all installations, namely pure Python installs. So, we need a mechanism to declare whether a compression engine is available. We don't want to conditionally register the compression engine because it is sometimes useful to know when a compression engine name or encountered data is valid but just not available versus unknown. diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -3047,6 +3047,15 @@ class compressionengine(object): """ raise NotImplementedError() + def available(self): + """Whether the compression engine is available. + + The intent of this method is to allow optional compression engines + that may not be available in all installations (such as engines relying + on C extensions that may not be present). + """ + return True + def bundletype(self): """Describes bundle identifiers for this engine.