[PATCH 3 of 8] util: expose an "available" API on compression engines
Gregory Szorc
gregory.szorc at gmail.com
Fri Nov 11 04:23:35 EST 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1478847828 28800
# Thu Nov 10 23:03:48 2016 -0800
# Node ID 13fccc619c0d8627d05d07f4a51d67a87bf2ca62
# Parent 32c2b8ca42a574f83426eaa19c89a8ff51c0e6de
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
@@ -2955,6 +2955,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.
More information about the Mercurial-devel
mailing list