Debian Codegraph @

tests/helpers-testrepo.sh

raw
1 # In most cases, the mercurial repository can be read by the bundled hg, but
2 # that isn't always true because third-party extensions may change the store
3 # format, for example. In which case, the system hg installation is used.
4 #
5 # We want to use the hg version being tested when interacting with the test
6 # repository, and the system hg when interacting with the mercurial source code
7 # repository.
8 #
9 # The mercurial source repository was typically orignally cloned with the
10 # system mercurial installation, and may require extensions or settings from
11 # the system installation.
12
13 if [ -n "$HGTESTEXTRAEXTENSIONS" ]; then
14 for extension in $HGTESTEXTRAEXTENSIONS; do
15 extraoptions="$extraoptions --config extensions.$extension=!"
16 done
17 fi
18
19 syshg () {
20 (
21 syshgenv
22 exec hg "$@"
23 )
24 }
25
26 # Revert the environment so that running "hg" runs the system hg
27 # rather than the test hg installation.
28 syshgenv () {
29 . "$HGTEST_RESTOREENV"
30 HGPLAIN=1
31 export HGPLAIN
32 if [ -n "$HGTEST_BASE_HGMODULEPOLICY" ]; then
33 HGMODULEPOLICY="$HGTEST_BASE_HGMODULEPOLICY"
34 else
35 unset HGMODULEPOLICY
36 fi
37 export HGMODULEPOLICY
38 }
39
40 # The test-repo is a live hg repository which may have evolution markers
41 # created, e.g. when a ~/.hgrc enabled evolution.
42 #
43 # Tests may be run using a custom HGRCPATH, which do not enable evolution
44 # markers by default.
45 #
46 # If test-repo includes evolution markers, and we do not enable evolution
47 # markers, hg will occasionally complain when it notices them, which disrupts
48 # tests resulting in sporadic failures.
49 #
50 # Since we aren't performing any write operations on the test-repo, there's
51 # no harm in telling hg that we support evolution markers, which is what the
52 # following lines for the hgrc file do:
53 cat >> "$HGRCPATH" << EOF
54 [experimental]
55 evolution = createmarkers
56 EOF
57
58 # Use the system hg command if the bundled hg can't read the repository with
59 # no warning nor error.
60 if [ -n "`hg id -R "$TESTDIR/.." 2>&1 >/dev/null`" ]; then
61 testrepohg() {
62 syshg "$@"
63 }
64 testrepohgenv() {
65 syshgenv "$@"
66 }
67 else
68 testrepohg() {
69 hg $extraoptions "$@"
70 }
71 testrepohgenv() {
72 :
73 }
74 fi