mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
e50c916cc3
Summary: There is redundant code in the codebase relating to fetching configuration for database for the purpose of testing. This commit refactors some code which enables removing the redundant code. Reviewed By: quark-zju Differential Revision: D8961806 fbshipit-source-id: f673bfffb80304d98987c9727f6e709fdb742813
107 lines
1.9 KiB
Bash
107 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
scratchnodes() {
|
|
for node in `find ../repo/.hg/scratchbranches/index/nodemap/* | sort`; do
|
|
echo ${node##*/} `cat $node`
|
|
done
|
|
}
|
|
|
|
scratchbookmarks() {
|
|
for bookmark in `find ../repo/.hg/scratchbranches/index/bookmarkmap/* -type f | sort`; do
|
|
echo "${bookmark##*/bookmarkmap/} `cat $bookmark`"
|
|
done
|
|
}
|
|
|
|
setupcommon() {
|
|
cat >> $HGRCPATH << EOF
|
|
[extensions]
|
|
commitcloud=
|
|
infinitepush=
|
|
infinitepushbackup=
|
|
pullcreatemarkers=
|
|
[ui]
|
|
ssh = python "$TESTDIR/dummyssh"
|
|
[infinitepush]
|
|
branchpattern=re:scratch/.*
|
|
bgssh = python "$TESTDIR/dummyssh" -bgssh
|
|
EOF
|
|
}
|
|
|
|
setupserver() {
|
|
cat >> .hg/hgrc << EOF
|
|
[infinitepush]
|
|
server=yes
|
|
indextype=disk
|
|
storetype=disk
|
|
reponame=babar
|
|
EOF
|
|
}
|
|
|
|
setupsqlclienthgrc() {
|
|
cat << EOF > .hg/hgrc
|
|
[ui]
|
|
ssh=python "$TESTDIR/dummyssh"
|
|
[extensions]
|
|
infinitepush=
|
|
[infinitepush]
|
|
branchpattern=re:scratch/.+
|
|
server=False
|
|
[paths]
|
|
default = ssh://user@dummy/server
|
|
EOF
|
|
}
|
|
|
|
setupsqlserverhgrc() {
|
|
cat << EOF > .hg/hgrc
|
|
[ui]
|
|
ssh=python "$TESTDIR/dummyssh"
|
|
[extensions]
|
|
infinitepush=
|
|
[infinitepush]
|
|
branchpattern=re:scratch/.+
|
|
server=True
|
|
indextype=sql
|
|
storetype=disk
|
|
reponame=$1
|
|
EOF
|
|
}
|
|
|
|
createdb() {
|
|
mysql -h $DBHOST -P $DBPORT -u $DBUSER $DBPASSOPT -e "CREATE DATABASE IF NOT EXISTS $DBNAME;" 2>/dev/null
|
|
mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT <<EOF
|
|
DROP TABLE IF EXISTS nodestobundle;
|
|
DROP TABLE IF EXISTS bookmarkstonode;
|
|
DROP TABLE IF EXISTS bundles;
|
|
DROP TABLE IF EXISTS nodesmetadata;
|
|
$(cat $TESTDIR/infinitepush/schema.sql)
|
|
EOF
|
|
}
|
|
|
|
setupdb() {
|
|
source "$TESTDIR/hgsql/library.sh"
|
|
echo "sqlhost=$DBHOST:$DBPORT:$DBNAME:$DBUSER:$DBPASS" >> .hg/hgrc
|
|
|
|
createdb
|
|
}
|
|
|
|
waitbgbackup() {
|
|
sleep 1
|
|
hg debugwaitbackup
|
|
}
|
|
|
|
mkcommitautobackup() {
|
|
echo $1 > $1
|
|
hg add $1
|
|
hg ci -m $1 --config infinitepushbackup.autobackup=True
|
|
}
|
|
|
|
setuplogdir() {
|
|
mkdir $TESTTMP/logs
|
|
chmod 0755 $TESTTMP/logs
|
|
chmod +t $TESTTMP/logs
|
|
}
|
|
|
|
debugsshcall() {
|
|
sed -n '/^running .*dummyssh.*$/p'
|
|
}
|