[PATCH 1 of 2] Add allowfallbackext function for pure python fallbacks

Brendan Cully brendan at kublai.com
Tue Dec 30 21:00:52 CST 2008


# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1230692335 28800
# Node ID b7048751b5eec7ba2626c52cdef99dfd3c1509af
# Parent  6abb141724c51b4d4d481e7d9ddd6cce4449010d
Add allowfallbackext function for pure python fallbacks
Fallback implementations should call this function before doing anything else.
If the HGALLOWFALLBACKS environment variable is not set, this function will
issue a warning and abort.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -655,6 +655,12 @@
     global _hgexecutable
     _hgexecutable = path
 
+def allowfallbackext(ext):
+    allowed = os.environ.get('HGALLOWFALLBACKS', '0').lower()
+    if allowed not in ('1', 'y', 'yes', 'true'):
+        raise Abort(_("C extension '%s' unavailable and "
+                      "HGALLOWFALLBACKS is false") % ext)
+
 def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None):
     '''enhanced shell command execution.
     run with environment maybe modified, maybe in different dir.


More information about the Mercurial-devel mailing list