Comments
Patch
@@ -1,37 +1,58 @@
-# Invoke the system hg installation (rather than the local hg version being
-# tested).
+# This file defines syshg and syshgenv functions to use for calling
+# hg on the hg repository itself ($TESTDIR/..)
#
-# 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.
+# Interacting with the hg repository may need to be done differently than
+# interacting with the temporary repositories created for testing purposes.
+# The hg repository will generally have been created by the user with the
+# system hg command from the user's $PATH, using the default system
+# configuration settings from /etc/mercurial. The temporary test repositories
+# use our local hg script, with a controlled HGRCPATH that does not include the
+# standard system settings. These two configurations may be incompatible.
#
-# 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 "$@"
- )
-}
+# First try to use our local hg script. If it can successfully interact with
+# the local repository we just use that.
+#
+# Otherwise try to use the system hg installation. We ensure that it is at
+# least new enough to include the "hg files" command, since many of the check
+# tests rely on this command.
+#
+# If neither of these work, we exit with status 80 to skip the test.
-# Revert the environment so that running "hg" runs the system hg
-# rather than the test hg installation.
-syshgenv () {
+realsyshgenv () {
. "$HGTEST_RESTOREENV"
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() {
+realsyshg () {
+ (
+ realsyshgenv
+ exec hg "$@"
+ )
+}
+
+if hg --cwd "$TESTDIR/.." log -r. -Ttest >/dev/null 2>/dev/null; then
+ # If our local hg command works with the test HGRCPATH settings,
+ # just use it.
+ syshgenv () {
+ :
+ }
+ syshg () {
hg "$@"
}
- syshgenv() {
- :
+elif realsyshg --cwd "$TESTDIR/.." log -r. -Ttest >/dev/null 2>/dev/null && \
+ realsyshg files -h >/dev/null 2>/dev/null; then
+ # Otherwise, if the local hg command does not work but hg from $PATH works
+ # with an unmodified $HGRCPATH, use it.
+ syshgenv () {
+ realsyshgenv
}
+ syshg () {
+ realsyshg "$@"
+ }
+else
+ # We couldn't find an hg installation capable of interacting with
+ # the $TESTDIR/.. repository. Skip the test.
+ echo "unable to find hg capable of interacting with local repository"
+ exit 80
fi
@@ -1,5 +1,3 @@
- $ . "$TESTDIR/helpers-testrepo.sh"
-
Testing that hghave does not crash when checking features
$ hghave --test-features 2>/dev/null
@@ -21,7 +19,7 @@
> foo
> EOF
$ ( \
- > syshgenv; \
+ > . "$HGTEST_RESTOREENV"; \
> $TESTDIR/run-tests.py $HGTEST_RUN_TESTS_PURE test-hghaveaddon.t \
> )
.