sapling/eden/scm/tests/tinit.sh

185 lines
3.8 KiB
Bash
Raw Normal View History

# This file will be sourced by all .t tests. Put general purposed functions
# here.
_repocount=0
if [ -n "$USE_MONONOKE" ] ; then
. "$TESTDIR/../../../scm/mononoke/tests/integration/library.sh"
fi
# 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
}
newserver() {
local reponame="$1"
if [ -n "$USE_MONONOKE" ] ; then
REPONAME=$reponame setup_mononoke_config
mononoke
wait_for_mononoke "$TESTTMP/$reponame"
else
mkdir "$TESTTMP/$reponame"
cd "$TESTTMP/$reponame"
hg init --config extensions.lz4revlog=
cat >> ".hg/hgrc" <<EOF
[extensions]
lz4revlog=
remotefilelog=
remotenames=
treemanifest=
[remotefilelog]
reponame=$reponame
server=True
[treemanifest]
flatcompat=False
rustmanifest=True
server=True
treeonly=True
EOF
fi
}
clone() {
servername="$1"
clientname="$2"
shift 2
cd "$TESTTMP"
remotecmd="hg"
if [ -n "$USE_MONONOKE" ] ; then
remotecmd="$MONONOKE_HGCLI"
fi
hg clone -q --shallow "ssh://user@dummy/$servername" "$clientname" "$@" \
--config "extensions.lz4revlog=" \
--config "extensions.remotefilelog=" \
--config "extensions.remotenames=" \
--config "extensions.treemanifest=" \
--config "remotefilelog.reponame=$servername" \
--config "treemanifest.treeonly=True" \
--config "ui.ssh=$TESTDIR/dummyssh" \
--config "ui.remotecmd=$remotecmd"
cat >> $clientname/.hg/hgrc <<EOF
[extensions]
lz4revlog=
remotefilelog=
remotenames=
treemanifest=
tweakdefaults=
[phases]
publish=False
[remotefilelog]
reponame=$servername
[treemanifest]
flatcompat=False
rustmanifest=True
sendtrees=True
treeonly=True
[ui]
ssh=$TESTDIR/dummyssh
[tweakdefaults]
rebasekeepdate=True
EOF
if [ -n "$USE_MONONOKE" ] ; then
cat >> $clientname/.hg/hgrc <<EOF
[ui]
remotecmd=$MONONOKE_HGCLI
EOF
fi
}
switchrepo() {
reponame="$1"
cd $TESTTMP/$reponame
}
# Enable extensions or features
enable() {
local rcpath
# .hg/hgrc may not exist yet, so just check for requires
if [ -f .hg/requires ]; then
rcpath=.hg/hgrc
else
rcpath="$HGRCPATH"
fi
for name in "$@"; do
if [ "$name" = obsstore ]; then
cat >> $rcpath << EOF
[experimental]
evolution = createmarkers, allowunstable
EOF
else
cat >> $rcpath << EOF
[extensions]
$name=
EOF
fi
done
}
# 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 bookmarks -T '{bookmark}={node}\n'`
hg book -fd `hg book -T '{bookmark} '`
}
# Simplify error reporting so crash does not show a traceback.
# This is useful to match error messages without the traceback.
shorttraceback() {
enable errorredirect
hgsql: add a test demonstrating issues we saw with treeonly pushrebases Summary: This happens if during prepushrebase hook, a hgsql repo sync (db -> local) is completed by another process. `repo.manifestlog` does not get invalidated correctly if it's treeonly. The issue was partially detected by a C program modified from fanotify (2) manpage example monitoring `00manifesttree.i` changes: [00:32:35.780] pid 7734 opens 00manifesttree.i (size 1000264) # First open. [00:32:35.930] pid 7734 reads closes (no write) 00manifesttree.i (size 1000264) [00:32:38.685] pid 9175 opens 00manifesttree.i (size 1000264) [00:32:38.885] pid 9175 reads 00manifesttree.i (size 1000264) [00:32:38.886] pid 9175 closes (no write) 00manifesttree.i (size 1000264) [00:32:39.235] pid 9175 opens 00manifesttree.i (size 1000264) [00:32:39.235] pid 9175 closes (no write) 00manifesttree.i (size 1000264) [00:32:39.236] pid 9175 opens 00manifesttree.i (size 1000264) [00:32:39.236] pid 9175 modifies closes 00manifesttree.i (size 1000328) # Appended by another process. [00:32:41.169] pid 10759 opens 00manifesttree.i (size 1000328) [00:32:41.355] pid 10759 reads 00manifesttree.i (size 1000328) [00:32:41.355] pid 10759 closes (no write) 00manifesttree.i (size 1000328) [00:32:41.537] pid 10759 opens closes (no write) 00manifesttree.i (size 1000328) [00:32:41.537] pid 10759 opens 00manifesttree.i (size 1000392) [00:32:41.537] pid 10759 modifies closes 00manifesttree.i (size 1000392) # Appended by another process. [00:32:44.930] pid 7734 opens closes (no write) 00manifesttree.i (size 1000392) # Main process picked up changes. [00:32:44.930] pid 7734 opens 00manifesttree.i (size 1000392) [00:32:44.930] pid 7734 reads 00manifesttree.i (size 1000392) [00:32:44.930] pid 7734 modifies closes 00manifesttree.i (size 1000456) # Main process wrote data. [00:32:45.275] pid 7734 opens 00manifesttree.i (size 1000456) [00:32:45.459] pid 7734 reads 00manifesttree.i (size 1000456) [00:32:45.459] pid 7734 closes (no write) 00manifesttree.i (size 1000456) [00:32:45.550] pid 7734 opens closes (no write) 00manifesttree.i (size 1000456) [00:32:45.550] pid 7734 opens 00manifesttree.i (size 1000264) [00:32:45.550] pid 7734 closes 00manifesttree.i (size 1000264) # Main process truncated to the wrong position. Pid 7734 had "IntegrityError: 1062 (23000): Duplicate entry" error. The fanotify log showed it truncated the revlog to a wrong location, indicating an outdated revlog was kept in memory. The C program was sent as D10418991. Reviewed By: DurhamG Differential Revision: D10417797 fbshipit-source-id: 7ccc0a976d05efbca5b3ed6fb5ff7886766d06d2
2018-10-18 06:02:12 +03:00
setconfig errorredirect.script='printf "%s" "$TRACE" | tail -1 1>&2'
}
# Set config items like --config way, instead of using cat >> $HGRCPATH
setconfig() {
python "$RUNTESTDIR/setconfig.py" "$@"
}
# 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"
}
showgraph() {
hg log --graph -T "{rev} {node|short} {desc|firstline}" | sed \$d
}
tglog() {
hg log -G -T "{rev}: {node|short} '{desc}' {bookmarks} {branches}" "$@"
}
tglogp() {
hg log -G -T "{rev}: {node|short} {phase} '{desc}' {bookmarks} {branches}" "$@"
}
tglogm() {
hg log -G -T "{rev}: {node|short} '{desc|firstline}' {bookmarks} {join(mutations % '(Rewritten using {operation} into {join(successors % \'{node|short}\', \', \')})', ' ')}" "$@"
}