From 058c791b75168448a152e93d1d54e189f413fc63 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Tue, 25 Feb 2020 11:51:36 -0800 Subject: [PATCH] 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. --- hg-fast-export.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hg-fast-export.sh b/hg-fast-export.sh index 06d791c..6533452 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -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