tests/helpers-testrepo.sh
author Yuya Nishihara <yuya@tcha.org>
Sun, 02 Jul 2017 13:20:28 +0900
changeset 33205 2d7300cf3f3f
parent 33204 ddd65b4f3ae6
child 33206 45d6e2767a93
permissions -rw-r--r--
tests: restore workaround of obsolete warning from 3c9066ed557c It's simple and works well unless you are using third-party extensions that changes the store format.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     1
# Invoke the system hg installation (rather than the local hg version being
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     2
# tested).
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff changeset
     3
#
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     4
# We want to use the hg version being tested when interacting with the test
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     5
# repository, and the system hg when interacting with the mercurial source code
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     6
# repository.
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff changeset
     7
#
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     8
# The mercurial source repository was typically orignally cloned with the
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     9
# system mercurial installation, and may require extensions or settings from
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    10
# the system installation.
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    11
syshg () {
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    12
    (
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    13
        syshgenv
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    14
        exec hg "$@"
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    15
    )
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    16
}
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    17
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    18
# Revert the environment so that running "hg" runs the system hg
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    19
# rather than the test hg installation.
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    20
syshgenv () {
33126
98e2c78e309c tests: more completely restore the environment in syshgenv
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
    21
    . "$HGTEST_RESTOREENV"
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    22
    HGPLAIN=1
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    23
    export HGPLAIN
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    24
}
33125
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    25
33205
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    26
# The test-repo is a live hg repository which may have evolution markers
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    27
# created, e.g. when a ~/.hgrc enabled evolution.
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    28
#
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    29
# Tests may be run using a custom HGRCPATH, which do not enable evolution
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    30
# markers by default.
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    31
#
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    32
# If test-repo includes evolution markers, and we do not enable evolution
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    33
# markers, hg will occasionally complain when it notices them, which disrupts
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    34
# tests resulting in sporadic failures.
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    35
#
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    36
# Since we aren't performing any write operations on the test-repo, there's
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    37
# no harm in telling hg that we support evolution markers, which is what the
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    38
# following lines for the hgrc file do:
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    39
cat >> "$HGRCPATH" << EOF
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    40
[experimental]
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    41
evolution = createmarkers
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    42
EOF
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    43
33125
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    44
# Most test-check-* sourcing this file run "hg files", which is not available
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    45
# in ancient versions of hg. So we double check if "syshg files" works and
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    46
# fallback to hg bundled in the repo.
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    47
syshg files -h >/dev/null 2>/dev/null
33204
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    48
if [ $? -eq 0 ]; then
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    49
    alias testrepohg=syshg
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    50
    alias testrepohgenv=syshgenv
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    51
else
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    52
    alias testrepohg=hg
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    53
    alias testrepohgenv=:
33125
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    54
fi