2018-03-02 11:48:18 +03:00
|
|
|
# This file will be sourced by all .t tests. Put general purposed functions
|
|
|
|
# here.
|
|
|
|
|
|
|
|
_repocount=0
|
|
|
|
|
2019-05-29 11:27:22 +03:00
|
|
|
if [ -n "$USE_MONONOKE" ] ; then
|
|
|
|
. "$TESTDIR/../../mononoke/tests/integration/library.sh"
|
|
|
|
fi
|
|
|
|
|
2018-03-02 11:48:18 +03:00
|
|
|
# Create a new repo
|
|
|
|
newrepo() {
|
|
|
|
reponame="$1"
|
|
|
|
if [ -z "$reponame" ]; then
|
|
|
|
_repocount=$((_repocount+1))
|
|
|
|
reponame=repo$_repocount
|
|
|
|
fi
|
|
|
|
mkdir "$TESTTMP/$reponame"
|
|
|
|
cd "$TESTTMP/$reponame"
|
|
|
|
hg init
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:12:27 +03:00
|
|
|
newserver() {
|
2019-05-29 11:27:22 +03:00
|
|
|
local reponame="$1"
|
|
|
|
if [ -n "$USE_MONONOKE" ] ; then
|
2019-09-23 22:29:23 +03:00
|
|
|
REPONAME=$reponame setup_mononoke_config
|
2019-05-29 11:27:22 +03:00
|
|
|
mononoke
|
|
|
|
wait_for_mononoke "$TESTTMP/$reponame"
|
|
|
|
else
|
|
|
|
mkdir "$TESTTMP/$reponame"
|
|
|
|
cd "$TESTTMP/$reponame"
|
|
|
|
hg init --config extensions.lz4revlog=
|
2019-05-28 13:12:27 +03:00
|
|
|
|
2019-05-29 11:27:22 +03:00
|
|
|
cat >> ".hg/hgrc" <<EOF
|
2019-05-28 13:12:27 +03:00
|
|
|
[extensions]
|
2019-05-28 13:12:27 +03:00
|
|
|
lz4revlog=
|
2019-05-28 13:12:27 +03:00
|
|
|
remotefilelog=
|
2019-05-28 13:12:27 +03:00
|
|
|
remotenames=
|
2019-05-28 13:12:27 +03:00
|
|
|
treemanifest=
|
|
|
|
|
|
|
|
[remotefilelog]
|
|
|
|
reponame=$reponame
|
|
|
|
server=True
|
|
|
|
|
|
|
|
[treemanifest]
|
2019-05-28 13:12:27 +03:00
|
|
|
flatcompat=False
|
2019-10-04 20:47:53 +03:00
|
|
|
rustmanifest=True
|
2019-05-28 13:12:27 +03:00
|
|
|
server=True
|
|
|
|
treeonly=True
|
|
|
|
EOF
|
2019-05-29 11:27:22 +03:00
|
|
|
fi
|
2019-05-28 13:12:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
clone() {
|
|
|
|
servername="$1"
|
|
|
|
clientname="$2"
|
|
|
|
shift 2
|
|
|
|
cd "$TESTTMP"
|
2019-05-28 13:12:27 +03:00
|
|
|
remotecmd="hg"
|
2019-05-29 11:27:22 +03:00
|
|
|
if [ -n "$USE_MONONOKE" ] ; then
|
|
|
|
remotecmd="$MONONOKE_HGCLI"
|
|
|
|
fi
|
2019-05-28 13:12:27 +03:00
|
|
|
hg clone -q --shallow "ssh://user@dummy/$servername" "$clientname" "$@" \
|
|
|
|
--config "extensions.lz4revlog=" \
|
2019-05-28 13:12:27 +03:00
|
|
|
--config "extensions.remotefilelog=" \
|
2019-05-28 13:12:27 +03:00
|
|
|
--config "extensions.remotenames=" \
|
2019-05-28 13:12:27 +03:00
|
|
|
--config "extensions.treemanifest=" \
|
|
|
|
--config "remotefilelog.reponame=$servername" \
|
2019-05-28 13:12:27 +03:00
|
|
|
--config "treemanifest.treeonly=True" \
|
|
|
|
--config "ui.ssh=$TESTDIR/dummyssh" \
|
|
|
|
--config "ui.remotecmd=$remotecmd"
|
2019-05-28 13:12:27 +03:00
|
|
|
|
|
|
|
cat >> $clientname/.hg/hgrc <<EOF
|
|
|
|
[extensions]
|
2019-05-28 13:12:27 +03:00
|
|
|
lz4revlog=
|
2019-05-28 13:12:27 +03:00
|
|
|
remotefilelog=
|
2019-05-28 13:12:27 +03:00
|
|
|
remotenames=
|
2019-05-28 13:12:27 +03:00
|
|
|
treemanifest=
|
2019-05-28 13:12:27 +03:00
|
|
|
tweakdefaults=
|
2019-05-28 13:12:27 +03:00
|
|
|
|
|
|
|
[phases]
|
|
|
|
publish=False
|
|
|
|
|
|
|
|
[remotefilelog]
|
|
|
|
reponame=$servername
|
|
|
|
|
|
|
|
[treemanifest]
|
2019-05-28 13:12:27 +03:00
|
|
|
flatcompat=False
|
2019-10-04 20:47:53 +03:00
|
|
|
rustmanifest=True
|
2019-05-28 13:12:27 +03:00
|
|
|
sendtrees=True
|
2019-05-28 13:12:27 +03:00
|
|
|
treeonly=True
|
2019-05-28 13:12:27 +03:00
|
|
|
|
|
|
|
[ui]
|
|
|
|
ssh=$TESTDIR/dummyssh
|
2019-08-08 20:18:43 +03:00
|
|
|
|
|
|
|
[tweakdefaults]
|
|
|
|
rebasekeepdate=True
|
2019-05-28 13:12:27 +03:00
|
|
|
EOF
|
|
|
|
|
2019-05-29 11:27:22 +03:00
|
|
|
if [ -n "$USE_MONONOKE" ] ; then
|
|
|
|
cat >> $clientname/.hg/hgrc <<EOF
|
|
|
|
[ui]
|
|
|
|
remotecmd=$MONONOKE_HGCLI
|
|
|
|
EOF
|
|
|
|
fi
|
2019-05-28 13:12:27 +03:00
|
|
|
}
|
|
|
|
|
2018-10-03 18:46:12 +03:00
|
|
|
switchrepo() {
|
|
|
|
reponame="$1"
|
|
|
|
cd $TESTTMP/$reponame
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:48:18 +03:00
|
|
|
# Enable extensions or features
|
|
|
|
enable() {
|
2018-09-21 20:16:05 +03:00
|
|
|
local rcpath
|
2018-11-21 19:31:30 +03:00
|
|
|
# .hg/hgrc may not exist yet, so just check for requires
|
|
|
|
if [ -f .hg/requires ]; then
|
2018-09-21 20:16:05 +03:00
|
|
|
rcpath=.hg/hgrc
|
|
|
|
else
|
|
|
|
rcpath="$HGRCPATH"
|
|
|
|
fi
|
2018-03-02 11:48:18 +03:00
|
|
|
for name in "$@"; do
|
|
|
|
if [ "$name" = obsstore ]; then
|
2018-09-21 20:16:05 +03:00
|
|
|
cat >> $rcpath << EOF
|
2018-03-02 11:48:18 +03:00
|
|
|
[experimental]
|
|
|
|
evolution = createmarkers, allowunstable
|
|
|
|
EOF
|
|
|
|
else
|
2018-09-21 20:16:05 +03:00
|
|
|
cat >> $rcpath << EOF
|
2018-03-02 11:48:18 +03:00
|
|
|
[extensions]
|
|
|
|
$name=
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2018-03-02 11:48:19 +03:00
|
|
|
|
|
|
|
# Like "hg debugdrawdag", but do not leave local tags in the repo and define
|
|
|
|
# nodes as environment variables.
|
|
|
|
# This is useful if the test wants to hide those commits because tags would
|
|
|
|
# make commits visible. The function will set environment variables so
|
|
|
|
# commits can still be referred as $TAGNAME.
|
|
|
|
drawdag() {
|
|
|
|
hg debugdrawdag "$@"
|
|
|
|
eval `hg tags -T '{tag}={node}\n'`
|
|
|
|
rm -f .hg/localtags
|
|
|
|
}
|
|
|
|
|
2018-08-17 21:26:35 +03:00
|
|
|
# Simplify error reporting so crash does not show a traceback.
|
|
|
|
# This is useful to match error messages without the traceback.
|
|
|
|
shorttraceback() {
|
|
|
|
enable errorredirect
|
2018-10-18 06:02:12 +03:00
|
|
|
setconfig errorredirect.script='printf "%s" "$TRACE" | tail -1 1>&2'
|
2018-08-17 21:26:35 +03:00
|
|
|
}
|
|
|
|
|
2018-03-02 11:48:19 +03:00
|
|
|
# Set config items like --config way, instead of using cat >> $HGRCPATH
|
|
|
|
setconfig() {
|
|
|
|
python "$RUNTESTDIR/setconfig.py" "$@"
|
|
|
|
}
|
2018-08-15 09:13:15 +03:00
|
|
|
|
2018-09-12 05:43:00 +03:00
|
|
|
# Create a new extension
|
|
|
|
newext() {
|
|
|
|
extname="$1"
|
|
|
|
if [ -z "$extname" ]; then
|
|
|
|
_extcount=$((_extcount+1))
|
|
|
|
extname=ext$_extcount
|
|
|
|
fi
|
|
|
|
cat > "$TESTTMP/$extname.py"
|
|
|
|
setconfig "extensions.$extname=$TESTTMP/$extname.py"
|
|
|
|
}
|
|
|
|
|
2018-08-15 09:13:15 +03:00
|
|
|
showgraph() {
|
2018-08-15 09:13:17 +03:00
|
|
|
hg log --graph -T "{rev} {node|short} {desc|firstline}" | sed \$d
|
2018-08-15 09:13:15 +03:00
|
|
|
}
|
2018-08-16 20:37:29 +03:00
|
|
|
|
|
|
|
tglog() {
|
|
|
|
hg log -G -T "{rev}: {node|short} '{desc}' {bookmarks} {branches}" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
tglogp() {
|
|
|
|
hg log -G -T "{rev}: {node|short} {phase} '{desc}' {bookmarks} {branches}" "$@"
|
|
|
|
}
|
2019-04-11 17:45:38 +03:00
|
|
|
|
|
|
|
tglogm() {
|
2019-04-11 17:45:39 +03:00
|
|
|
hg log -G -T "{rev}: {node|short} '{desc|firstline}' {bookmarks} {join(mutations % '(Rewritten using {operation} into {join(successors % \'{node|short}\', \', \')})', ' ')}" "$@"
|
2019-04-11 17:45:38 +03:00
|
|
|
}
|