tests/helpers-testrepo.sh
author Jun Wu <quark@fb.com>
Wed, 28 Jun 2017 13:45:51 -0700
changeset 33132 acfce52518c4
parent 33128 6c113a7dec52
child 33133 98e2c78e309c
permissions -rw-r--r--
tests: do not use system hg if it does not have "files" command Ancient hg does not have "hg files" so test-check-*.t will fail with "unknown command 'files'": $ hg files hg: unknown command 'files' $ hg --version Mercurial Distributed SCM (version 2.6.2) Test "hg files" and give up using syshg if it does not have "files" command.

# Invoke the system hg installation (rather than the local hg version being
# tested).
#
# We want to use the hg version being tested when interacting with the test
# repository, and the system hg when interacting with the mercurial source code
# repository.
#
# The mercurial source repository was typically orignally cloned with the
# system mercurial installation, and may require extensions or settings from
# the system installation.
syshg () {
    (
        syshgenv
        exec hg "$@"
    )
}

# Revert the environment so that running "hg" runs the system hg
# rather than the test hg installation.
syshgenv () {
    PATH="$ORIG_PATH"
    PYTHONPATH="$ORIG_PYTHONPATH"
    JYTHONPATH="$ORIG_JYTHONPATH"
    unset HGRCPATH
    HGPLAIN=1
    export HGPLAIN
}

# Most test-check-* sourcing this file run "hg files", which is not available
# in ancient versions of hg. So we double check if "syshg files" works and
# fallback to hg bundled in the repo.
syshg files -h >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
    syshg() {
        hg "$@"
    }
    syshgenv() {
        :
    }
fi