Check python's mercurial version for compatibility

When checking that python has the mercurial package in hg-fast-export.sh,
use the same import statement that is used in hg-fast-export.py.

hg-fast-export.py imports revsymbol from mercurial.scmutil,
which was introduced in mercurial 4.6, but Ubuntu 18.04 only has
mercurial 4.5.3 using python2, so an incompatible python version may be
chosen without this change.
This commit is contained in:
Steven Peters
2020-02-25 11:51:36 -08:00
parent 13010f7a25
commit 058c791b75

View File

@@ -31,7 +31,7 @@ if [ -z "${PYTHON}" ]; then
# $PYTHON is not set, so we try to find a working python with mercurial:
for python_cmd in python2 python python3; do
if command -v $python_cmd > /dev/null; then
$python_cmd -c 'import mercurial' 2> /dev/null
$python_cmd -c 'from mercurial.scmutil import revsymbol' 2> /dev/null
if [ $? -eq 0 ]; then
PYTHON=$python_cmd
break
@@ -40,7 +40,7 @@ if [ -z "${PYTHON}" ]; then
done
fi
if [ -z "${PYTHON}" ]; then
echo "Could not find a python interpreter with the mercurial module available. " \
echo "Could not find a python interpreter with the mercurial module >= 4.6 available. " \
"Please use the 'PYTHON' environment variable to specify the interpreter to use."
exit 1
fi