tests/test-push-http
author Sune Foldager <cryo@cyanite.org>
Thu, 15 Apr 2010 21:59:21 +0200
branchstable
changeset 10925 a101a743c570
parent 10398 ace3cf2bc991
child 11469 c37f35d7f2f5
permissions -rwxr-xr-x
prepush: rewrite most of the code from scratch For servers with branchmap support, the algorithm now works as follows: 1. A list of branches in outgoing changesets is created. 2. Using the remote branchmap, a check for new branches is performed. 3. A map (from branch to head list) of locally known remote heads before the push is created, and one which, after step 4, will contain the locally known remote heads after the push. 4. The post-push head map is updated with the outgoing changesets, using the branch cache update mechanism. 5. A check for new heads is performed, by comparing the length of the head list before and after push, for each branch. If there are new heads, an error depending on whether or not there are incoming changes on the branch, is returned. 6. If the push is allowed, a warning is written if there are incoming changes on any branches involved in the push. For old servers, an algorithm similar to step 4-6 above is used to check for new topological heads only. Two bugs are also fixed: 1. Sometimes you would be allowed to push new branch heads without --force. A test for this case was added. 2. You would get the "note: unsynced remote changes!" warning if there were any incoming changesets, even if they were on unrelated branches.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     2
4288
8a3e12426c03 test-push-http: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
     3
cp "$TESTDIR"/printenv.py .
8a3e12426c03 test-push-http: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
     4
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     5
hg init test
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     6
cd test
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     7
echo a > a
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 6167
diff changeset
     8
hg ci -Ama
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     9
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    10
cd ..
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    11
hg clone test test2
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    12
cd test2
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    13
echo a >> a
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 6167
diff changeset
    14
hg ci -mb
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    15
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    16
req() {
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    17
	hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    18
	cat hg.pid >> $DAEMON_PIDS
10398
ace3cf2bc991 tests: don't just silently strip port numbers
Mads Kiilerich <mads@kiilerich.com>
parents: 8167
diff changeset
    19
	hg --cwd ../test2 push http://localhost:$HGPORT/ | sed -e "s,:$HGPORT/,:\$HGPORT/,"
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    20
	kill `cat hg.pid`
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    21
	echo % serve errors
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    22
	cat errors.log
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    23
}
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    24
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    25
cd ../test
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    26
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    27
echo % expect ssl error
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    28
req
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    29
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    30
echo % expect authorization error
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    31
echo '[web]' > .hg/hgrc
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    32
echo 'push_ssl = false' >> .hg/hgrc
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    33
req
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    34
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    35
echo % expect authorization error: must have authorized user
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    36
echo 'allow_push = unperson' >> .hg/hgrc
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    37
req
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    38
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    39
echo % expect success
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    40
echo 'allow_push = *' >> .hg/hgrc
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2571
diff changeset
    41
echo '[hooks]' >> .hg/hgrc
4288
8a3e12426c03 test-push-http: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
    42
echo 'changegroup = python ../printenv.py changegroup 0 ../urls' >> .hg/hgrc
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    43
req
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    44
4288
8a3e12426c03 test-push-http: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
    45
cat ../urls
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2571
diff changeset
    46
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    47
hg rollback
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    48
echo % expect authorization error: all users denied
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2571
diff changeset
    49
echo '[web]' > .hg/hgrc
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2571
diff changeset
    50
echo 'push_ssl = false' >> .hg/hgrc
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    51
echo 'deny_push = *' >> .hg/hgrc
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    52
req
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    53
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    54
echo % expect authorization error: some users denied, users must be authenticated
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    55
echo 'deny_push = unperson' >> .hg/hgrc
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    56
req