##// END OF EJS Templates
errors: catch urllib errors specifically instead of using safehasattr()...
errors: catch urllib errors specifically instead of using safehasattr() Before this patch, we would catch `IOError` and `OSError` and check if the instance had a `.code` member (indicates `HTTPError`) or a `.reason` member (indicates the more generic `URLError`). It seems to me that can simply catch those exception specifically instead, so that's what this code does. The existing code is from fbe8834923c5 (commands: report http exceptions nicely, 2005-06-17), so I suspect it's just that there was no `urllib2` (where `URLError` lives) back then. The old code mentioned `SSLError` in a comment. The new code does *not* try to catch that. The documentation for `ssl.SSLError` says that it has a `.reason` property, but `python -c 'import ssl; print(dir(ssl.SSLError("foo", Exception("bar"))))` doesn't mention that property on either Python 2 or Python 3 on my system. It also seems that `sslutil` is pretty careful about converting `ssl.SSLError` to `error.Abort`. It also is carefult to not assume that instances of the exception have a `.reason`. So I at least don't want to catch `ssl.SSLError` and handle it the same way as `URLError` because that would likely result in a crash. I also wonder if we don't need to handle it at all (because `sslutil` might handle all the cases). It's now early in the release cycle, so perhaps we can just see how it goes? Differential Revision: https://phab.mercurial-scm.org/D9318

File last commit:

r41725:549af2fa default
r46442:ae00e170 default
Show More
test-largefiles-wireproto.t
452 lines | 14.3 KiB | text/troff | Tads3Lexer
/ tests / test-largefiles-wireproto.t
Gregory Szorc
tests: test using both versions of SSH protocol...
r36235 #testcases sshv1 sshv2
#if sshv2
$ cat >> $HGRCPATH << EOF
> [experimental]
> sshpeer.advertise-v2 = true
> sshserver.support-v2 = true
> EOF
#endif
Mads Kiilerich
spelling: fixes from proofreading of spell checker issues
r23139 This file contains testcases that tend to be related to the wire protocol part
of largefiles.
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424
$ USERCACHE="$TESTTMP/cache"; export USERCACHE
$ mkdir "${USERCACHE}"
$ cat >> $HGRCPATH <<EOF
> [extensions]
> largefiles=
> purge=
> rebase=
> transplant=
> [phases]
> publish=False
> [largefiles]
> minsize=2
> patterns=glob:**.dat
> usercache=${USERCACHE}
Matt Harbison
largefiles: restore archiving largefiles with hgweb (issue4859)...
r26417 > [web]
David Demelier
config: rename allow_archive to allow-archive...
r38215 > allow-archive = zip
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 > [hooks]
> precommit=sh -c "echo \\"Invoking status precommit hook\\"; hg status"
> EOF
#if serve
vanilla clients not locked out from largefiles servers on vanilla repos
$ mkdir r1
$ cd r1
$ hg init
$ echo c1 > f1
$ hg add f1
$ hg commit -m "m1"
Invoking status precommit hook
A f1
$ cd ..
$ hg serve -R r1 -d -p $HGPORT --pid-file hg.pid
$ cat hg.pid >> $DAEMON_PIDS
$ hg --config extensions.largefiles=! clone http://localhost:$HGPORT r2
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Boris Feld
phase: report number of non-public changeset alongside the new range...
r39516 new changesets b6eb3a2e2efe (1 drafts)
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
largefiles clients still work with vanilla servers
Jun Wu
tests: reorder hg serve commands...
r28549 $ hg serve --config extensions.largefiles=! -R r1 -d -p $HGPORT1 --pid-file hg.pid
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 $ cat hg.pid >> $DAEMON_PIDS
$ hg clone http://localhost:$HGPORT1 r3
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Boris Feld
phase: report number of non-public changeset alongside the new range...
r39516 new changesets b6eb3a2e2efe (1 drafts)
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
#endif
vanilla clients locked out from largefiles http repos
$ mkdir r4
$ cd r4
$ hg init
$ echo c1 > f1
$ hg add --large f1
$ hg commit -m "m1"
Invoking status precommit hook
A f1
$ cd ..
largefiles can be pushed locally (issue3583)
$ hg init dest
$ cd r4
$ hg outgoing ../dest
comparing with ../dest
searching for changes
changeset: 0:639881c12b4c
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: m1
$ hg push ../dest
pushing to ../dest
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
exit code with nothing outgoing (issue3611)
$ hg outgoing ../dest
comparing with ../dest
searching for changes
no changes found
[1]
$ cd ..
#if serve
$ hg serve -R r4 -d -p $HGPORT2 --pid-file hg.pid
$ cat hg.pid >> $DAEMON_PIDS
$ hg --config extensions.largefiles=! clone http://localhost:$HGPORT2 r5
abort: remote error:
This repository uses the largefiles extension.
Please enable it in your Mercurial config file.
[255]
used all HGPORTs, kill all daemons
Matt Mackall
tests: drop DAEMON_PIDS from killdaemons calls
r25474 $ killdaemons.py
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 #endif
vanilla clients locked out from largefiles ssh repos
Matt Harbison
tests: quote $PYTHON for Windows...
r33335 $ hg --config extensions.largefiles=! clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/r4 r5
Pierre-Yves David
sshpeer: break "OutOfBandError" feature for ssh (BC)...
r25243 remote:
remote: This repository uses the largefiles extension.
remote:
remote: Please enable it in your Mercurial config file.
remote:
remote: -
abort: remote error
(check previous remote output)
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 [255]
#if serve
largefiles clients refuse to push largefiles repos to vanilla servers
$ mkdir r6
$ cd r6
$ hg init
$ echo c1 > f1
$ hg add f1
$ hg commit -m "m1"
Invoking status precommit hook
A f1
$ cat >> .hg/hgrc <<!
> [web]
> push_ssl = false
> allow_push = *
> !
$ cd ..
$ hg clone r6 r7
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd r7
$ echo c2 > f2
$ hg add --large f2
$ hg commit -m "m2"
Invoking status precommit hook
A f2
liscju
largefiles: check file in the repo store before checking remotely (issue5257)...
r29421 $ hg verify --large
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
Meirambek Omyrzak
verify: make output less confusing (issue5924)...
r39525 checked 2 changesets with 2 changes to 2 files
liscju
largefiles: check file in the repo store before checking remotely (issue5257)...
r29421 searching 1 changesets for largefiles
verified existence of 1 revisions of 1 largefiles
Jun Wu
tests: reorder hg serve commands...
r28549 $ hg serve --config extensions.largefiles=! -R ../r6 -d -p $HGPORT --pid-file ../hg.pid
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 $ cat ../hg.pid >> $DAEMON_PIDS
$ hg push http://localhost:$HGPORT
pushing to http://localhost:$HGPORT/
searching for changes
abort: http://localhost:$HGPORT/ does not appear to be a largefile store
[255]
$ cd ..
putlfile errors are shown (issue3123)
Corrupt the cached largefile in r7 and move it out of the servers usercache
$ mv r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 .
$ echo 'client side corruption' > r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
$ rm "$USERCACHE/4cdac4d8b084d0b599525cf732437fb337d422a8"
$ hg init empty
$ hg serve -R empty -d -p $HGPORT1 --pid-file hg.pid \
> --config 'web.allow_push=*' --config web.push_ssl=False
$ cat hg.pid >> $DAEMON_PIDS
$ hg push -R r7 http://localhost:$HGPORT1
pushing to http://localhost:$HGPORT1/
searching for changes
remote: largefiles: failed to put 4cdac4d8b084d0b599525cf732437fb337d422a8 into store: largefile contents do not match hash
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 abort: remotestore: could not put $TESTTMP/r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 to remote store http://localhost:$HGPORT1/
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 [255]
$ mv 4cdac4d8b084d0b599525cf732437fb337d422a8 r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
Push of file that exists on server but is corrupted - magic healing would be nice ... but too magic
$ echo "server side corruption" > empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
$ hg push -R r7 http://localhost:$HGPORT1
pushing to http://localhost:$HGPORT1/
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 2 changes to 2 files
$ cat empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
server side corruption
$ rm -rf empty
Push a largefiles repository to a served empty repository
$ hg init r8
$ echo c3 > r8/f1
$ hg add --large r8/f1 -R r8
$ hg commit -m "m1" -R r8
Invoking status precommit hook
A f1
$ hg init empty
$ hg serve -R empty -d -p $HGPORT2 --pid-file hg.pid \
> --config 'web.allow_push=*' --config web.push_ssl=False
$ cat hg.pid >> $DAEMON_PIDS
$ rm "${USERCACHE}"/*
$ hg push -R r8 http://localhost:$HGPORT2/#default
pushing to http://localhost:$HGPORT2/
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
$ [ -f "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
$ [ -f empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
Clone over http, no largefiles pulled on clone.
$ hg clone http://localhost:$HGPORT2/#default http-clone -U
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Boris Feld
phase: report number of non-public changeset alongside the new range...
r39516 new changesets cf03e5bb9936 (1 drafts)
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424
Matt Harbison
largefiles: restore archiving largefiles with hgweb (issue4859)...
r26417 Archive contains largefiles
Augie Fackler
tests: update test-largefiles-wireproto to pass our import checker
r33965 >>> import os
Matt Harbison
py3: adapt test-largefiles-wireproto.t to python3
r40906 >>> from mercurial import urllibcompat
Matt Harbison
largefiles: restore archiving largefiles with hgweb (issue4859)...
r26417 >>> u = 'http://localhost:%s/archive/default.zip' % os.environ['HGPORT2']
Matt Harbison
py3: adapt test-largefiles-wireproto.t to python3
r40906 >>> with open('archive.zip', 'wb') as f:
... f.write(urllibcompat.urlreq.urlopen(u).read()) and None
Matt Harbison
largefiles: restore archiving largefiles with hgweb (issue4859)...
r26417 $ unzip -t archive.zip
Archive: archive.zip
Augie Fackler
tests: glob whitespace between path and OK in unzip(1) output...
r29562 testing: empty-default/.hg_archival.txt*OK (glob)
testing: empty-default/f1*OK (glob)
Matt Harbison
largefiles: restore archiving largefiles with hgweb (issue4859)...
r26417 No errors detected in compressed data of archive.zip.
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 test 'verify' with remotestore:
$ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90
$ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
$ hg -R http-clone verify --large --lfa
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
Meirambek Omyrzak
verify: make output less confusing (issue5924)...
r39525 checked 1 changesets with 1 changes to 1 files
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 searching 1 changesets for largefiles
changeset 0:cf03e5bb9936: f1 missing
verified existence of 1 revisions of 1 largefiles
[1]
$ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/
$ hg -R http-clone -q verify --large --lfa
largefiles pulled on update - a largefile missing on the server:
$ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
$ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
getting changed largefiles
f1: largefile 02a439e5c31c526465ab1a0ca1f431f76b827b90 not available from http://localhost:$HGPORT2/
0 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg -R http-clone st
! f1
$ hg -R http-clone up -Cqr null
largefiles pulled on update - a largefile corrupted on the server:
$ echo corruption > empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90
$ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
getting changed largefiles
f1: data corruption (expected 02a439e5c31c526465ab1a0ca1f431f76b827b90, got 6a7bb2556144babe3899b25e5428123735bb1e27)
0 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg -R http-clone st
! f1
$ [ ! -f http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
$ [ ! -f http-clone/f1 ]
$ [ ! -f http-clone-usercache ]
$ hg -R http-clone verify --large --lfc
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
Meirambek Omyrzak
verify: make output less confusing (issue5924)...
r39525 checked 1 changesets with 1 changes to 1 files
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 searching 1 changesets for largefiles
verified contents of 1 revisions of 1 largefiles
$ hg -R http-clone up -Cqr null
largefiles pulled on update - no server side problems:
$ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/
Pierre-Yves David
progress: get the extremely verbose output out of default debug...
r25125 $ hg -R http-clone --debug up --config largefiles.usercache=http-clone-usercache --config progress.debug=true
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 resolving manifests
branchmerge: False, force: False, partial: False
ancestor: 000000000000, local: 000000000000+, remote: cf03e5bb9936
.hglf/f1: remote created -> g
getting .hglf/f1
updating: .hglf/f1 1/1 files (100.00%)
getting changed largefiles
using http://localhost:$HGPORT2/
sending capabilities command
Gregory Szorc
largefiles: use command executor for batch operation...
r37650 sending statlfile command
av6
largefiles: specify unit for ui.progress when operating on files...
r28463 getting largefiles: 0/1 files (0.00%)
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 getting f1:02a439e5c31c526465ab1a0ca1f431f76b827b90
sending getlfile command
found 02a439e5c31c526465ab1a0ca1f431f76b827b90 in store
1 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ ls http-clone-usercache/*
http-clone-usercache/02a439e5c31c526465ab1a0ca1f431f76b827b90
$ rm -rf empty http-clone*
used all HGPORTs, kill all daemons
Matt Mackall
tests: drop DAEMON_PIDS from killdaemons calls
r25474 $ killdaemons.py
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424
liscju
largefiles: makes verify batching stat calls to remote...
r29068 largefiles should batch verify remote calls
$ hg init batchverifymain
$ cd batchverifymain
$ echo "aaa" >> a
$ hg add --large a
$ hg commit -m "a"
Invoking status precommit hook
A a
$ echo "bbb" >> b
$ hg add --large b
$ hg commit -m "b"
Invoking status precommit hook
A b
$ cd ..
$ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \
> -A access.log
$ cat hg.pid >> $DAEMON_PIDS
liscju
largefiles: send statlfile remote calls only for nonexisting locally files...
r29218 $ hg clone --noupdate http://localhost:$HGPORT batchverifyclone
liscju
largefiles: makes verify batching stat calls to remote...
r29068 requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
Boris Feld
phase: report number of non-public changeset alongside the new range...
r39516 new changesets 567253b0f523:04d19c27a332 (2 drafts)
liscju
largefiles: send statlfile remote calls only for nonexisting locally files...
r29218 $ hg -R batchverifyclone verify --large --lfa
liscju
largefiles: makes verify batching stat calls to remote...
r29068 checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
Meirambek Omyrzak
verify: make output less confusing (issue5924)...
r39525 checked 2 changesets with 2 changes to 2 files
liscju
largefiles: send statlfile remote calls only for nonexisting locally files...
r29218 searching 2 changesets for largefiles
liscju
largefiles: makes verify batching stat calls to remote...
r29068 verified existence of 2 revisions of 2 largefiles
$ tail -1 access.log
Joerg Sonnenberger
wireproto: support for pullbundles...
r37516 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
liscju
largefiles: send statlfile remote calls only for nonexisting locally files...
r29218 $ hg -R batchverifyclone update
getting changed largefiles
2 largefiles updated, 0 removed
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
Clear log file before next test
$ printf "" > access.log
Verify should check file on remote server only when file is not
available locally.
$ echo "ccc" >> batchverifymain/c
$ hg -R batchverifymain status
? c
$ hg -R batchverifymain add --large batchverifymain/c
$ hg -R batchverifymain commit -m "c"
Invoking status precommit hook
A c
$ hg -R batchverifyclone pull
pulling from http://localhost:$HGPORT/
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Boris Feld
phase: report number of non-public changeset alongside the new range...
r39516 new changesets 6bba8cb6935d (1 drafts)
liscju
largefiles: send statlfile remote calls only for nonexisting locally files...
r29218 (run 'hg update' to get a working copy)
$ hg -R batchverifyclone verify --lfa
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
Meirambek Omyrzak
verify: make output less confusing (issue5924)...
r39525 checked 3 changesets with 3 changes to 3 files
liscju
largefiles: send statlfile remote calls only for nonexisting locally files...
r29218 searching 3 changesets for largefiles
verified existence of 3 revisions of 3 largefiles
$ tail -1 access.log
Gregory Szorc
largefiles: use command executor for batch operation...
r37650 $LOCALIP - - [$LOGDATE$] "GET /?cmd=statlfile HTTP/1.1" 200 - x-hgarg-1:sha=c8559c3c9cfb42131794b7d8009230403b9b454c x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
liscju
largefiles: makes verify batching stat calls to remote...
r29068
$ killdaemons.py
Mads Kiilerich
spelling: fixes of non-dictionary words
r30332 largefiles should not ask for password again after successful authorization
liscju
largefiles: make cloning not ask two times about password (issue4883)...
r29379
$ hg init credentialmain
$ cd credentialmain
$ echo "aaa" >> a
$ hg add --large a
$ hg commit -m "a"
Invoking status precommit hook
A a
Before running server clear the user cache to force clone to download
a large file from the server rather than to get it from the cache
$ rm "${USERCACHE}"/*
$ cd ..
Matt Harbison
tests: extract the http server authentication extension to a single module...
r41725
$ hg serve --config extensions.x=$TESTDIR/httpserverauth.py -R credentialmain \
liscju
largefiles: make cloning not ask two times about password (issue4883)...
r29379 > -d -p $HGPORT --pid-file hg.pid -A access.log
$ cat hg.pid >> $DAEMON_PIDS
$ cat << EOF > get_pass.py
> import getpass
> def newgetpass(arg):
> return "pass"
> getpass.getpass = newgetpass
> EOF
$ hg clone --config ui.interactive=true --config extensions.getpass=get_pass.py \
> http://user@localhost:$HGPORT credentialclone
http authorization required for http://localhost:$HGPORT/
realm: mercurial
user: user
Gregory Szorc
wireproto: declare operation type for most commands (BC) (SEC)...
r36772 password: requesting all changes
adding changesets
liscju
largefiles: make cloning not ask two times about password (issue4883)...
r29379 adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Boris Feld
phase: report number of non-public changeset alongside the new range...
r39516 new changesets 567253b0f523 (1 drafts)
liscju
largefiles: make cloning not ask two times about password (issue4883)...
r29379 updating to branch default
getting changed largefiles
1 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Matt Harbison
test-serve: kill daemons before deleting the access and error logs...
r31770 $ killdaemons.py
liscju
largefiles: make cloning not ask two times about password (issue4883)...
r29379 $ rm hg.pid access.log
Pierre-Yves David
test: split test-largefile.t in multiple file...
r21424 #endif