changeset 30437:64d7275445d0

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 10 Nov 2016 23:03:48 -0800
parents 788ea4ac4388
children 90933e4e44fd
files mercurial/util.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Thu Nov 10 22:26:35 2016 -0800
+++ b/mercurial/util.py	Thu Nov 10 23:03:48 2016 -0800
@@ -3047,6 +3047,15 @@
         """
         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.