tests/helpers-testrepo.sh
author Pierre-Yves David <pierre-yves.david@octobus.net>
Mon, 19 Jun 2017 01:08:11 +0200
changeset 33137 31ab1912678a
parent 33133 98e2c78e309c
child 33204 ddd65b4f3ae6
permissions -rw-r--r--
obsolete: skip 'changectx' usage in unstable computation We simplify the unstable computation code, skipping the expensive creation of changectx object. We focus on efficient set operation and revnumber centric functions. In my mercurial development repository, this provides a 3x speedup to the function: before: 5.319 ms after: 1.844 ms repo details: total changesets: 40886 obsolete changesets: 7756 mutable (not obsolete): 293 unstable: 30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    30
if [ $? -ne 0 ]; then
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    31
    syshg() {
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    32
        hg "$@"
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    33
    }
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    34
    syshgenv() {
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    35
        :
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    36
    }
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33128
diff changeset
    37
fi