mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
4a936cee21
Summary: Previously, the following pattern is common in our tests: ``` $ extpath=`dirname $TESTDIR` $ cp $extpath/hgext3rd/name.py $TESTTMP # use $TESTTMP substitution in message $ cat >> $HGRCPATH<<EOF > [extensions] > name=$TESTTMP/name.py > EOF ``` Now, it gets simplified to: ``` $ cat >> $HGRCPATH<<EOF > [extensions] > name=$TESTDIR/../hgext3rd/name.py > EOF ``` This removes unnecessary `dirname` and `cp`. Also fixed a regex that does not match `bytes`: ``` - transferred 268 bytes in [\d.]+ seconds \([\d.]+ KB/sec\) (re) + transferred 268 bytes in 0.3 seconds (939 bytes/sec) ``` Test Plan: arc unit Reviewers: #mercurial, phillco Reviewed By: phillco Subscribers: medson, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D5270897 Signature: t1:5270897:1497663052:bf860a0b480c751b1e4b53cebf6526193f0f6652
99 lines
2.1 KiB
Bash
99 lines
2.1 KiB
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]
|
|
infinitepush=$TESTDIR/../infinitepush
|
|
[ui]
|
|
ssh = python "$TESTDIR/dummyssh"
|
|
[infinitepush]
|
|
branchpattern=re:scratch/.*
|
|
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=$TESTDIR/../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=$TESTDIR/../infinitepush
|
|
[infinitepush]
|
|
branchpattern=re:scratch/.+
|
|
server=True
|
|
indextype=sql
|
|
storetype=disk
|
|
reponame=$1
|
|
EOF
|
|
}
|
|
|
|
createdb() {
|
|
mysql -h $DBHOST -P $DBPORT -u $DBUSER -p"$DBPASS" -e "CREATE DATABASE IF NOT EXISTS $DBNAME;" 2>/dev/null
|
|
mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER -p"$DBPASS" <<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() {
|
|
[[ -e $TESTDIR/getdb.sh ]] || { echo 'skipped: missing getdb.sh'; exit 80; }
|
|
source $TESTDIR/getdb.sh >/dev/null
|
|
|
|
if [[ -z $DBHOST && -z $DBPORT && -n $DBHOSTPORT ]]; then
|
|
# Assuming they are set using the legacy way: $DBHOSTPORT
|
|
DBHOST=`echo $DBHOSTPORT | cut -d : -f 1`
|
|
DBPORT=`echo $DBHOSTPORT | cut -d : -f 2`
|
|
fi
|
|
|
|
[[ -z $DBHOST ]] && DBHOST=localhost
|
|
[[ -z $DBPORT ]] && DBPORT=3306
|
|
[[ -z $DBPASS && -n $PASSWORD ]] && DBPASS="$PASSWORD"
|
|
[[ -z $DBUSER && -n $USER ]] && DBUSER="$USER"
|
|
[[ -z $DBNAME ]] && DBNAME="testdb_hg_$$_$TIME"
|
|
|
|
echo "sqlhost=$DBHOST:$DBPORT:$DBNAME:$DBUSER:$DBPASS" >> .hg/hgrc
|
|
|
|
createdb
|
|
}
|
|
|
|
waitbgbackup() {
|
|
sleep 1
|
|
hg debugwaitbackup
|
|
}
|