tests/test-init
author Renato Cunha <renatoc@gmail.com>
Tue, 03 Aug 2010 13:41:47 -0300
changeset 11747 40d5633889bb
parent 11640 c3e8ab80ee90
permissions -rwxr-xr-x
hgfixes: add a fixer to convert plain strings to bytestrings This patch implements a 2to3 fixer that converts all plain strings in a python source file to byte strings syntax. Example: foo = 'Normal string' would become foo = b'Normal string' The motivation behind this fixer can be found in http://selenic.com/pipermail/mercurial-devel/2010-June/022363.html or, in other words: the current hg source assumes that _most_ strings are "meant" to be byte sequences, so it makes sense to make the convertion implemented by this patch. As mentioned above, not all mercurial modules want to use strings as bytes, examples include i18n (which uses unicode), and demandimport (in py3k, module names are normal strings, thus unicode, and there's no need for a convertion). Therefore, these modules are blacklisted in the fixer. There are also a few functions that can take only unicode arguments, thus the convertion shouldn't be done for those.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     1
#!/bin/sh
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     2
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     3
# This test tries to exercise the ssh functionality with a dummy script
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     4
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     5
cat <<EOF > dummyssh
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     6
import sys
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     7
import os
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     8
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     9
os.chdir(os.path.dirname(sys.argv[0]))
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    10
if sys.argv[1] != "user@dummy":
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    11
    sys.exit(-1)
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    12
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    13
if not os.path.exists("dummyssh"):
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    14
    sys.exit(-1)
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    15
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    16
log = open("dummylog", "ab")
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    17
log.write("Got arguments")
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    18
for i, arg in enumerate(sys.argv[1:]):
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    19
    log.write(" %d:%s" % (i+1, arg))
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    20
log.write("\n")
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    21
log.close()
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    22
r = os.system(sys.argv[2])
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    23
sys.exit(bool(r))
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    24
EOF
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    25
4166
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    26
checknewrepo()
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    27
{
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    28
    name=$1
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    29
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    30
    if [ -d $name/.hg/store ]; then
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    31
	echo store created
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    32
    fi
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    33
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    34
    if [ -f $name/.hg/00changelog.i ]; then
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    35
	echo 00changelog.i created
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    36
    fi
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    37
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    38
    cat $name/.hg/requires
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    39
}
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    40
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    41
echo "# creating 'local'"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    42
hg init local
4166
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    43
checknewrepo local
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    44
echo this > local/foo
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    45
hg ci --cwd local -A -m "init" -d "1000000 0"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    46
7249
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    47
echo "# creating repo with format.usestore=false"
4166
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    48
hg --config format.usestore=false init old
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    49
checknewrepo old
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    50
7249
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    51
echo "# creating repo with format.usefncache=false"
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    52
hg --config format.usefncache=false init old2
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    53
checknewrepo old2
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    54
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    55
echo "#test failure"
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    56
hg init local
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    57
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    58
echo "# init+push to remote2"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    59
hg init -e "python ./dummyssh" ssh://user@dummy/remote2
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    60
hg incoming -R remote2 local
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    61
hg push -R local -e "python ./dummyssh" ssh://user@dummy/remote2
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    62
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    63
echo "# clone to remote1"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    64
hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    65
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    66
echo "# init to existing repo"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    67
hg init -e "python ./dummyssh" ssh://user@dummy/remote1
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    68
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    69
echo "# clone to existing repo"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    70
hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    71
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    72
echo "# output of dummyssh"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    73
cat dummylog
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    74
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    75
echo "# comparing repositories"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    76
hg tip -q -R local
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    77
hg tip -q -R remote1
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    78
hg tip -q -R remote2
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    79
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    80
echo "# check names for repositories (clashes with URL schemes, special chars)"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    81
for i in bundle file hg http https old-http ssh static-http " " "with space"; do
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    82
  echo "# hg init \"$i\""
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    83
  hg init "$i"
3713
8ae88ed2a3b6 don't create the .hg/data at init time
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3037
diff changeset
    84
  test -d "$i" -a -d "$i/.hg" && echo "ok" || echo "failed"
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    85
done
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    86
11640
c3e8ab80ee90 init: create target directory recursively
Mads Kiilerich <mads@kiilerich.com>
parents: 7249
diff changeset
    87
echo "# creating 'local/sub/repo'"
c3e8ab80ee90 init: create target directory recursively
Mads Kiilerich <mads@kiilerich.com>
parents: 7249
diff changeset
    88
hg init local/sub/repo
c3e8ab80ee90 init: create target directory recursively
Mads Kiilerich <mads@kiilerich.com>
parents: 7249
diff changeset
    89
checknewrepo local/sub/repo