##// END OF EJS Templates
bookmark: use `list_paths` to access path definition...
bookmark: use `list_paths` to access path definition The content of the `[paths]` config section is receiving transformation that make it hard to recognise whats the actual name, and the next changeset will make it worse. So we use the official API for this instead. Differential Revision: https://phab.mercurial-scm.org/D10448

File last commit:

r42094:cae3f7e3 default
r47959:353718f7 default
Show More
discovery-helper.sh
107 lines | 2.6 KiB | application/x-sh | BashLexer
contrib: move the `discovery-helper.sh` script in`perf-utils` directory...
r42059 #!/bin/bash
#
# produces two repositories with different common and missing subsets
#
# $ discovery-helper.sh REPO NBHEADS DEPT
#
# The Goal is to produce two repositories with some common part and some
# exclusive part on each side. Provide a source repository REPO, it will
# produce two repositories REPO-left and REPO-right.
#
# Each repository will be missing some revisions exclusive to NBHEADS of the
# repo topological heads. These heads and revisions exclusive to them (up to
# DEPTH depth) are stripped.
#
# The "left" repository will use the NBHEADS first heads (sorted by
# description). The "right" use the last NBHEADS one.
#
# To find out how many topological heads a repo has, use:
#
# $ hg heads -t -T '{rev}\n' | wc -l
#
# Example:
#
# The `pypy-2018-09-01` repository has 192 heads. To produce two repositories
# with 92 common heads and ~50 exclusive heads on each side.
#
# $ ./discovery-helper.sh pypy-2018-08-01 50 10
set -euo pipefail
discovery-helper: add an extra argument to generate only one repo...
r42091 printusage () {
echo "usage: `basename $0` REPO NBHEADS DEPTH [left|right]" >&2
}
contrib: move the `discovery-helper.sh` script in`perf-utils` directory...
r42059 if [ $# -lt 3 ]; then
discovery-helper: add an extra argument to generate only one repo...
r42091 printusage
exit 64
contrib: move the `discovery-helper.sh` script in`perf-utils` directory...
r42059 fi
repo="$1"
shift
nbheads="$1"
shift
depth="$1"
shift
discovery-helper: add an extra argument to generate only one repo...
r42091 doleft=1
doright=1
if [ $# -gt 1 ]; then
printusage
exit 64
elif [ $# -eq 1 ]; then
if [ "$1" == "left" ]; then
doleft=1
doright=0
elif [ "$1" == "right" ]; then
doleft=0
doright=1
else
printusage
exit 64
fi
fi
discovery-helper: reflect argument value in the name of the results...
r42061 leftrepo="${repo}-${nbheads}h-${depth}d-left"
rightrepo="${repo}-${nbheads}h-${depth}d-right"
contrib: move the `discovery-helper.sh` script in`perf-utils` directory...
r42059
left="first(sort(heads(all()), 'desc'), $nbheads)"
right="last(sort(heads(all()), 'desc'), $nbheads)"
leftsubset="ancestors($left, $depth) and only($left, heads(all() - $left))"
rightsubset="ancestors($right, $depth) and only($right, heads(all() - $right))"
discovery-helper: echo the stripped revsets early...
r42060 echo '### creating left/right repositories with missing changesets:'
discovery-helper: add an extra argument to generate only one repo...
r42091 if [ $doleft -eq 1 ]; then
echo '# left revset:' '"'${leftsubset}'"'
fi
if [ $doright -eq 1 ]; then
echo '# right revset:' '"'${rightsubset}'"'
fi
discovery-helper: echo the stripped revsets early...
r42060
discovery-helper: move repository creation in a function...
r42092 buildone() {
discovery-helper: bail out if destination already exists
r42093 side="$1"
dest="$2"
revset="$3"
discovery-helper: move repository creation in a function...
r42092 echo "### building $side repository: $dest"
discovery-helper: bail out if destination already exists
r42093 if [ -e "$dest" ]; then
echo "destination repo already exists: $dest" >&2
exit 1
fi
discovery-helper: add an extra argument to generate only one repo...
r42091 echo '# cloning'
discovery-helper: use reflink copy if available...
r42094 if ! cp --recursive --reflink=always ${repo} ${dest}; then
hg clone --noupdate "${repo}" "${dest}"
fi
discovery-helper: move repository creation in a function...
r42092 echo '# stripping' '"'${revset}'"'
hg -R "${dest}" --config extensions.strip= strip --rev "$revset" --no-backup
}
if [ $doleft -eq 1 ]; then
discovery-helper: bail out if destination already exists
r42093 buildone left "$leftrepo" "$leftsubset"
discovery-helper: add an extra argument to generate only one repo...
r42091 fi
contrib: move the `discovery-helper.sh` script in`perf-utils` directory...
r42059
discovery-helper: add an extra argument to generate only one repo...
r42091 if [ $doright -eq 1 ]; then
discovery-helper: bail out if destination already exists
r42093 buildone right "$rightrepo" "$rightsubset"
discovery-helper: add an extra argument to generate only one repo...
r42091 fi