[PATCH 2 of 2] tests: use the system hg for examining the local repository

Yuya Nishihara yuya at tcha.org
Wed Jun 28 10:53:18 EDT 2017


On Tue, 27 Jun 2017 17:37:19 -0700, Adam Simpkins wrote:
> # HG changeset patch
> # User Adam Simpkins <simpkins at fb.com>
> # Date 1498609471 25200
> #      Tue Jun 27 17:24:31 2017 -0700
> # Node ID 148ea34a2581415b8df897f2b22720d2cd3afdf0
> # Parent  6ce24ed2fa3f7a10d632f29b0f2a2da100884ba6
> tests: use the system hg for examining the local repository
> 
> Most test scripts use "hg" to interact with a temporary test repository.
> However a few tests also want to run hg commands to interact with the local
> repository containing the mercurial source code.  Notably, many of the
> test-check-* tests want to check local files and commit messages.
> 
> These tests were previously using the version of hg being tested to query the
> source repository.  However, this will fail if the source repository requires
> extensions or other settings not supported by the version of mercurial being
> tested.  The source repository was typically initially cloned using the system
> hg installation, so we should use the system hg installation to query it.
> 
> There was already a helpers-testrepo.sh script designed to help cope with
> different requirements for the source repository versus the test repositories.
> However, it only handled the evolve extension.  This new behavior works with
> any extensions that are different between the system installation and the test
> installation.
> 
> diff --git a/tests/helpers-testrepo.sh b/tests/helpers-testrepo.sh
> --- a/tests/helpers-testrepo.sh
> +++ b/tests/helpers-testrepo.sh
> @@ -1,19 +1,27 @@
> -# The test-repo is a live hg repository which may have evolution
> -# markers created, e.g. when a ~/.hgrc enabled evolution.
> +# Invoke the system hg installation (rather than the local hg version being
> +# tested).
>  #
> -# Tests are run using a custom HGRCPATH, which do not
> -# enable evolution markers by default.
> +# 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.
>  #
> -# If test-repo includes evolution markers, and we do not
> -# enable evolution markers, hg will occasionally complain
> -# when it notices them, which disrupts tests resulting in
> -# sporadic failures.
> -#
> -# Since we aren't performing any write operations on the
> -# test-repo, there's no harm in telling hg that we support
> -# evolution markers, which is what the following lines
> -# for the hgrc file do:
> -cat >> $HGRCPATH << EOF
> -[experimental]
> -evolution=createmarkers
> -EOF
> +# The mercurial source repository was typically orignally cloned with the
> +# system mercurial installation, and may require extensions or settings from
> +# the system installation.
> +function syshg {
> +    (
> +        syshgenv
> +        exec hg "$@"
> +    )
> +}
> +
> +# Revert the environment so that running "hg" runs the system hg
> +# rather than the test hg installation.
> +function syshgenv {
> +    PATH="$ORIG_PATH"
> +    PYTHONPATH="$ORIG_PYTHONPATH"
> +    JYTHONPATH="$ORIG_JYTHONPATH"
> +    unset HGRCPATH
> +    HGPLAIN=1
> +    export HGPLAIN
> +}

Can this be an optional feature? It doesn't work if the system hg is a shell
script referring environment variables overridden by the test runner, notably
HOME.


More information about the Mercurial-devel mailing list