view tests/test-ssh @ 5149:ad6b97132b81

merge: fix a copy detection bug (issue672) When merging rev1 and rev2, we want to search for copies that happened in rev1 but not in rev2 and vice-versa. We were starting the search at rev1/rev2 and then going back, stopping as soon as we reached the revno of the ancestor, but that can miss some cases (see the new test-issue672). Now we calculate the revisions that are ancestors of rev1 or rev2 (but not both) and make sure the search doesn't stop too early. Simplified test provided by mpm, based on a test case provided by Edward Lee.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 12 Aug 2007 12:15:10 -0300
parents 58517f6eb1ad
children
line wrap: on
line source

#!/bin/sh

cp "$TESTDIR"/printenv.py .

# This test tries to exercise the ssh functionality with a dummy script

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))
EOF

echo "# creating 'remote'"
hg init remote
cd remote
echo this > foo
echo this > fooO
hg ci -A -m "init" -d "1000000 0" foo fooO
echo '[server]' > .hg/hgrc
echo 'uncompressed = True' >> .hg/hgrc
echo '[hooks]' >> .hg/hgrc
echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc

cd ..

echo "# repo not found error"
hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local

echo "# clone remote via stream"
hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
  sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
cd local-stream
hg verify
cd ..

echo "# clone remote via pull"
hg clone -e "python ./dummyssh" ssh://user@dummy/remote local

echo "# verify"
cd local
hg verify

echo '[hooks]' >> .hg/hgrc
echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc

echo "# empty default pull"
hg paths
hg pull -e "python ../dummyssh"

echo "# local change"
echo bleah > foo
hg ci -m "add" -d "1000000 0"

echo "# updating rc"
echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
echo "[ui]" >> .hg/hgrc
echo "ssh = python ../dummyssh" >> .hg/hgrc

echo "# find outgoing"
hg out ssh://user@dummy/remote

echo "# find incoming on the remote side"
hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local

echo "# push"
hg push

cd ../remote

echo "# check remote tip"
hg tip
hg verify
hg cat -r tip foo

echo z > z
hg ci -A -m z -d '1000001 0' z

cd ../local
echo r > r
hg ci -A -m z -d '1000002 0' r

echo "# push should succeed"
hg push

cd ..
cat dummylog