annotate tests/helpers-testrepo.sh @ 33204:ddd65b4f3ae6

tests: alias syshg and syshgenv so they can be switched conditionally
author Yuya Nishihara <yuya@tcha.org>
date Sun, 02 Jul 2017 13:14:20 +0900
parents 98e2c78e309c
children 2d7300cf3f3f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33128
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 #
33128
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 #
33128
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 () {
33133
98e2c78e309c tests: more completely restore the environment in syshgenv
Adam Simpkins <simpkins@fb.com>
parents: 33132
diff changeset
21 . "$HGTEST_RESTOREENV"
33128
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 }
33132
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
25
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
26 # 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: 33128
diff changeset
27 # 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: 33128
diff changeset
28 # 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: 33128
diff changeset
29 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: 33133
diff changeset
30 if [ $? -eq 0 ]; then
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33133
diff changeset
31 alias testrepohg=syshg
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33133
diff changeset
32 alias testrepohgenv=syshgenv
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33133
diff changeset
33 else
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33133
diff changeset
34 alias testrepohg=hg
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33133
diff changeset
35 alias testrepohgenv=:
33132
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
36 fi