#!/usr/bin/env bash
set -e

if [ -n "$TESTDIR" ]; then
  . "$TESTDIR/helpers-testrepo.sh"
  HG="${HG:-testrepohg}"
else
    HG="${HG:-hg}"
fi

HERE="$(dirname "$0")"
cd "$(dirname "$HERE")"

PYTHON="${PYTHON:-python3}"

$HG files 'set:**.py or grep(r"^#!.*?python")' \
  'glob:tests/**.t' \
  -X hgweb.cgi \
  -X setup.py \
  -X contrib/automation/ \
  -X contrib/debugshell.py \
  -X contrib/hgweb.fcgi \
  -X contrib/packaging/hg-docker \
  -X contrib/packaging/hgpackaging/ \
  -X contrib/packaging/inno/ \
  -X contrib/phab-clean.py \
  -X contrib/python-zstandard/ \
  -X contrib/win32/hgwebdir_wsgi.py \
  -X contrib/perf-utils/perf-revlog-write-plot.py \
  -X doc/gendoc.py \
  -X doc/hgmanpage.py \
  -X i18n/posplit \
  -X mercurial/thirdparty \
  -X tests/testlib/hypothesishelpers.py \
  -X tests/test-demandimport.py \
  -X tests/test-imports-checker.t \
  -X tests/test-verify-repo-operations.py \
  -X tests/test-extension.t \
  | sed 's-\\-/-g' | "$PYTHON" "contrib/import-checker.py" -
