sapling/tests/integration/library.sh
Stanislau Hlebik c0b25700db mononoke: add support many mfnodes and basemfnodes in gettreepack
Summary:
Quick recap: gettreepack is a treemanifest wireproto method.
It's used to send treemanifest data to the client. Client sends list of
manifest nodes it's interested in (mfnodes), and list of nodes it already has
(basemfnodes). Server should find the difference and send it back. Client
usually call this wireproto method when it checks out new revision (`hg
update`), but it uses in other cases too (for example, in `hg prefetch`).

Before we supported exactly one mfnode and exactly one basemfnode. This is
usually fine for `hg update` use-case, but `hg prefetch` can request many
mfnodes and can send empty basemfnode. So let's support this too.

Note that current implementation isn't efficient. It uses at most one
basemfnode, meaning that it can send data that client already has. Also for
each mfnode we generate separate stream of changed entries. That means that the
same entries can be fetched many times.

Reviewed By: lukaspiatkowski

Differential Revision: D6923197

fbshipit-source-id: d25f9a01ca568c84811ee1a13181e70eb217eb53
2018-02-14 06:36:04 -08:00

146 lines
2.5 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"
CONFIG
hg add -q repos
hg ci -ma
hg bookmark test-config
hg backfilltree
cd ..
}
function blobimport {
$MONONOKE_BLOBIMPORT "$@" >> "$TESTTMP/blobimport.out" 2>&1
}
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" "$@"
}
hgcloneshallow() {
local dest
orig=$1
shift
dest=$1
shift
hg clone --shallow --config remotefilelog.reponame=master "$orig" "$dest" "$@"
cat >> "$dest"/.hg/hgrc <<EOF
[remotefilelog]
reponame=master
datapackversion=1
[phases]
publish=False
EOF
}
function hginit_treemanifest() {
hg init "$@"
cat >> "$1"/.hg/hgrc <<EOF
[extensions]
treemanifest=
remotefilelog=
[treemanifest]
server=True
sendtrees=True
[remotefilelog]
reponame=$1
cachepath=$TESTTMP/hgcache
server=True
shallowtrees=True
EOF
}
function hgclone_treemanifest() {
hg clone "$@"
cat >> "$2"/.hg/hgrc <<EOF
[extensions]
treemanifest=
remotefilelog=
fastmanifest=
[treemanifest]
sendtrees=True
[remotefilelog]
reponame=$2
cachepath=$TESTTMP/hgcache
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
}