2005-08-28 05:11:32 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2007-03-27 06:50:04 +04:00
|
|
|
cp "$TESTDIR"/printenv.py .
|
|
|
|
|
2005-08-28 05:11:32 +04:00
|
|
|
# This test tries to exercise the ssh functionality with a dummy script
|
|
|
|
|
2007-03-27 08:41:22 +04:00
|
|
|
cat <<EOF > dummyssh
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
os.chdir(os.path.dirname(sys.argv[0]))
|
|
|
|
if sys.argv[1] != "user@dummy":
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
if not os.path.exists("dummyssh"):
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
|
|
|
|
|
|
|
|
log = open("dummylog", "ab")
|
|
|
|
log.write("Got arguments")
|
|
|
|
for i, arg in enumerate(sys.argv[1:]):
|
|
|
|
log.write(" %d:%s" % (i+1, arg))
|
|
|
|
log.write("\n")
|
|
|
|
log.close()
|
|
|
|
r = os.system(sys.argv[2])
|
|
|
|
sys.exit(bool(r))
|
2005-08-28 05:11:32 +04:00
|
|
|
EOF
|
|
|
|
|
2008-02-04 02:03:46 +03:00
|
|
|
cat <<EOF > badhook
|
|
|
|
import sys
|
2008-03-15 03:57:46 +03:00
|
|
|
sys.stdout.write("KABOOM\n")
|
2008-02-04 02:03:46 +03:00
|
|
|
EOF
|
|
|
|
|
2005-08-28 05:11:32 +04:00
|
|
|
echo "# creating 'remote'"
|
|
|
|
hg init remote
|
|
|
|
cd remote
|
|
|
|
echo this > foo
|
2006-12-01 15:34:09 +03:00
|
|
|
echo this > fooO
|
|
|
|
hg ci -A -m "init" -d "1000000 0" foo fooO
|
2006-07-16 03:06:35 +04:00
|
|
|
echo '[server]' > .hg/hgrc
|
2006-07-16 21:04:16 +04:00
|
|
|
echo 'uncompressed = True' >> .hg/hgrc
|
2006-07-26 00:50:32 +04:00
|
|
|
echo '[hooks]' >> .hg/hgrc
|
2007-03-27 06:50:04 +04:00
|
|
|
echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc
|
2005-08-28 05:11:32 +04:00
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
2006-10-06 18:24:14 +04:00
|
|
|
echo "# repo not found error"
|
2007-03-27 08:41:22 +04:00
|
|
|
hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
|
2006-10-06 18:24:14 +04:00
|
|
|
|
2006-07-14 22:17:22 +04:00
|
|
|
echo "# clone remote via stream"
|
2007-03-27 08:41:22 +04:00
|
|
|
hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
|
2006-08-21 21:46:58 +04:00
|
|
|
sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
|
2006-07-14 22:17:22 +04:00
|
|
|
cd local-stream
|
|
|
|
hg verify
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo "# clone remote via pull"
|
2007-03-27 08:41:22 +04:00
|
|
|
hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
|
2005-08-28 05:11:32 +04:00
|
|
|
|
|
|
|
echo "# verify"
|
|
|
|
cd local
|
|
|
|
hg verify
|
|
|
|
|
2006-07-26 00:50:32 +04:00
|
|
|
echo '[hooks]' >> .hg/hgrc
|
2007-03-27 06:50:04 +04:00
|
|
|
echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
|
2006-07-26 00:50:32 +04:00
|
|
|
|
2005-08-28 05:11:32 +04:00
|
|
|
echo "# empty default pull"
|
|
|
|
hg paths
|
2007-03-27 08:41:22 +04:00
|
|
|
hg pull -e "python ../dummyssh"
|
2005-08-28 05:11:32 +04:00
|
|
|
|
|
|
|
echo "# local change"
|
|
|
|
echo bleah > foo
|
2006-03-13 15:05:41 +03:00
|
|
|
hg ci -m "add" -d "1000000 0"
|
2005-08-28 05:11:32 +04:00
|
|
|
|
|
|
|
echo "# updating rc"
|
|
|
|
echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
|
|
|
|
echo "[ui]" >> .hg/hgrc
|
2007-03-27 08:41:22 +04:00
|
|
|
echo "ssh = python ../dummyssh" >> .hg/hgrc
|
2005-08-28 05:11:32 +04:00
|
|
|
|
|
|
|
echo "# find outgoing"
|
|
|
|
hg out ssh://user@dummy/remote
|
|
|
|
|
2006-03-21 14:15:25 +03:00
|
|
|
echo "# find incoming on the remote side"
|
2007-03-27 08:41:22 +04:00
|
|
|
hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local
|
2006-03-21 14:15:25 +03:00
|
|
|
|
2005-08-28 05:11:32 +04:00
|
|
|
echo "# push"
|
|
|
|
hg push
|
|
|
|
|
|
|
|
cd ../remote
|
|
|
|
|
|
|
|
echo "# check remote tip"
|
|
|
|
hg tip
|
|
|
|
hg verify
|
2006-09-15 06:24:00 +04:00
|
|
|
hg cat -r tip foo
|
2005-08-28 05:11:32 +04:00
|
|
|
|
2006-06-16 03:37:23 +04:00
|
|
|
echo z > z
|
|
|
|
hg ci -A -m z -d '1000001 0' z
|
2008-02-04 02:03:46 +03:00
|
|
|
# a bad, evil hook that prints to stdout
|
|
|
|
echo 'changegroup.stdout = python ../badhook' >> .hg/hgrc
|
2006-06-16 03:37:23 +04:00
|
|
|
|
|
|
|
cd ../local
|
|
|
|
echo r > r
|
|
|
|
hg ci -A -m z -d '1000002 0' r
|
|
|
|
|
2008-02-04 02:03:46 +03:00
|
|
|
echo "# push should succeed even though it has an unexpected response"
|
2006-11-20 01:32:36 +03:00
|
|
|
hg push
|
2008-02-04 02:03:46 +03:00
|
|
|
hg -R ../remote heads
|
2006-06-16 03:37:23 +04:00
|
|
|
|
2005-08-28 05:11:32 +04:00
|
|
|
cd ..
|
|
|
|
cat dummylog
|