diff --git a/hgsubversion/help/subversion.rst b/hgsubversion/help/subversion.rst index a963a1344f..89b80f5798 100644 --- a/hgsubversion/help/subversion.rst +++ b/hgsubversion/help/subversion.rst @@ -178,3 +178,11 @@ Please note that some of these options may be specified as command line options as well, and when done so, will override the configuration. If an authormap, filemap or branchmap is specified, its contents will be read and stored for use in future pulls. + +Finally, the following environment variables can be used for testing a +deployment of hgsubversion: + + HGSUBVERSION_BINDINGS + By default, hgsubversion will use Subvertpy, but fall back to the SWIG + bindings. Set this variable to either ``SWIG`` or ``Subvertpy`` (case- + insensitive) to force that set of bindings. diff --git a/hgsubversion/svnwrap/__init__.py b/hgsubversion/svnwrap/__init__.py index 980853b6de..a370fca3e1 100644 --- a/hgsubversion/svnwrap/__init__.py +++ b/hgsubversion/svnwrap/__init__.py @@ -8,11 +8,26 @@ present. from common import * -try: +import os + +choice = os.environ.get('HGSUBVERSION_BINDINGS', '').lower() + +if choice == 'subvertpy': from subvertpy_wrapper import * -except ImportError, e: +elif choice == 'swig': + from svn_swig_wrapper import * +elif choice == 'none': + # useful for verifying that demandimport works properly + raise ImportError('cannot use hgsubversion; ' + 'bindings disabled using HGSUBVERSION_BINDINGS') +else: try: - from svn_swig_wrapper import * - except ImportError: - # propagate the subvertpy error; it's easier to install - import subvertpy_wrapper + from subvertpy_wrapper import * + except ImportError, e: + try: + from svn_swig_wrapper import * + except ImportError: + # propagate the subvertpy error; it's easier to install + raise e + +del os, choice