sapling/tests/integration/library.sh
Lukas Piatkowski d24a501e9e blobrepo: write commit to HeadStore
Summary:
This is a hacky way of getting the push/pull working. We should instead remove the commits that are no longer heads from HeadStore and add those that are the new heads.
In this diff though we add all the commits as heads, just because this does not break the client

Reviewed By: farnz

Differential Revision: D7112279

fbshipit-source-id: 036f0fd230de52e96cbf4168c2cda7c2a1c5bd89
2018-02-28 14:15:13 -08:00

146 lines
2.7 KiB
Bash

#!/bin/bash
# Library routines and initial setup for Mononoke-related tests.
function mononoke {
$MONONOKE_SERVER "$@" --debug >> "$TESTTMP/mononoke.out" 2>&1 &
echo $! >> "$DAEMON_PIDS"
}
# Wait until a Mononoke server is available for this repo.
function wait_for_mononoke {
local socket="$1/.hg/mononoke.sock"
local attempts=50
until [[ -S $socket || $attempts -le 0 ]]; do
attempts=$((attempts - 1))
sleep 0.1
done
}
function setup_common_config {
setup_config_repo
cat >> "$HGRCPATH" <<EOF
[ui]
ssh="$DUMMYSSH"
[extensions]
remotefilelog=
[remotefilelog]
cachepath=$TESTTMP/cachepath
EOF
}
function setup_config_repo {
hg init mononoke-config
cd mononoke-config || exit
cat >> .hg/hgrc <<EOF
[extensions]
treemanifest=
remotefilelog=
[treemanifest]
server=True
[remotefilelog]
server=True
shallowtrees=True
EOF
mkdir repos
cat > repos/repo <<CONFIG
path="$TESTTMP/repo"
repotype="blob:files"
repoid=0
CONFIG
hg add -q repos
hg ci -ma
hg bookmark test-config
hg backfilltree
cd ..
}
function blobimport {
$MONONOKE_BLOBIMPORT "$@" >> "$TESTTMP/blobimport.out" 2>&1
reponame=$_
mkdir -p "$reponame"/.hg
mkdir -p "$reponame"/books
}
function edenserver {
$MONONOKE_EDEN_SERVER "$@" >> "$TESTTMP/edenserver.out" 2>&1 &
echo $! >> "$DAEMON_PIDS"
}
# Run an hg binary configured with the settings required to talk to Mononoke.
function hgmn {
hg --config ui.ssh="$DUMMYSSH" --config paths.default=ssh://user@dummy/repo --config ui.remotecmd="$MONONOKE_HGCLI" "$@"
}
function hgmn_show {
echo "LOG $*"
hgmn log --template 'node:\t{node}\np1node:\t{p1node}\np2node:\t{p2node}\nauthor:\t{author}\ndate:\t{date}\ndesc:\t{desc}\n\n{diff()}' -r "$@"
hgmn update "$@"
echo
echo "CONTENT $*"
find . -type f -not -path "./.hg/*" -print -exec cat {} \;
}
function hginit_treemanifest() {
hg init "$@"
cat >> "$1"/.hg/hgrc <<EOF
[extensions]
treemanifest=
remotefilelog=
smartlog=
[treemanifest]
server=True
sendtrees=True
[remotefilelog]
reponame=$1
cachepath=$TESTTMP/cachepath
server=True
shallowtrees=True
EOF
}
function hgclone_treemanifest() {
hg clone -q --shallow --config remotefilelog.reponame=master "$@"
cat >> "$2"/.hg/hgrc <<EOF
[extensions]
treemanifest=
remotefilelog=
fastmanifest=
smartlog=
[treemanifest]
sendtrees=True
treeonly=True
[remotefilelog]
reponame=$2
cachepath=$TESTTMP/cachepath
shallowtrees=True
EOF
}
function setup_hg_server() {
cat >> .hg/hgrc <<EOF
[extensions]
treemanifest=
remotefilelog=
[treemanifest]
server=True
[remotefilelog]
server=True
shallowtrees=True
EOF
}
function setup_hg_client() {
cat >> .hg/hgrc <<EOF
[extensions]
treemanifest=
remotefilelog=
[treemanifest]
server=False
treeonly=True
[remotefilelog]
server=False
reponame=repo
EOF
}