2017-02-10 05:02:52 +03:00
|
|
|
|
2015-06-29 23:43:54 +03:00
|
|
|
$ . "$TESTDIR/library.sh"
|
|
|
|
|
|
|
|
$ hginit master
|
|
|
|
$ cd master
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [remotefilelog]
|
|
|
|
> server=True
|
|
|
|
> EOF
|
|
|
|
$ echo x > x
|
|
|
|
$ hg commit -qAm x
|
2018-02-08 22:19:42 +03:00
|
|
|
$ hg serve -p 0 --port-file $TESTTMP/.port -d --pid-file=../hg1.pid -E ../error.log -A ../access.log
|
|
|
|
$ HGPORT=`cat $TESTTMP/.port`
|
2015-06-29 23:43:54 +03:00
|
|
|
|
2015-08-04 21:59:53 +03:00
|
|
|
Build a query string for later use:
|
|
|
|
$ GET=`hg debugdata -m 0 | python -c \
|
|
|
|
> 'import sys ; print [("?cmd=getfile&file=%s&node=%s" % tuple(s.split("\0"))) for s in sys.stdin.read().splitlines()][0]'`
|
|
|
|
|
2015-06-29 23:43:54 +03:00
|
|
|
$ cd ..
|
|
|
|
$ cat hg1.pid >> $DAEMON_PIDS
|
|
|
|
|
|
|
|
$ hgcloneshallow http://localhost:$HGPORT/ shallow -q
|
2015-07-01 00:32:31 +03:00
|
|
|
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
|
2015-06-30 00:33:56 +03:00
|
|
|
|
2015-08-21 19:51:40 +03:00
|
|
|
$ grep batch access.log | grep getfile
|
2015-11-04 23:56:01 +03:00
|
|
|
* "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=getfile+*node%3D1406e74118627694268417491f018a4a883152f0* (glob)
|
2015-08-21 19:51:40 +03:00
|
|
|
|
2015-08-18 22:14:01 +03:00
|
|
|
Clear filenode cache so we can test fetching with a modified batch size
|
|
|
|
$ rm -r $TESTTMP/hgcache
|
|
|
|
Now do a fetch with a large batch size so we're sure it works
|
|
|
|
$ hgcloneshallow http://localhost:$HGPORT/ shallow-large-batch \
|
|
|
|
> --config remotefilelog.batchsize=1000 -q
|
|
|
|
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
|
2015-06-29 23:43:54 +03:00
|
|
|
|
2015-06-30 00:36:25 +03:00
|
|
|
The 'remotefilelog' capability should *not* be exported over http(s),
|
|
|
|
as the getfile method it offers doesn't work with http.
|
2015-06-29 23:43:54 +03:00
|
|
|
$ get-with-headers.py localhost:$HGPORT '?cmd=capabilities'
|
|
|
|
200 Script output follows
|
|
|
|
|
2018-02-08 02:18:36 +03:00
|
|
|
lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream-preferred streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%2C03%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=*getflogheads getfile (no-eol) (glob)
|
2015-06-29 23:43:54 +03:00
|
|
|
$ get-with-headers.py localhost:$HGPORT '?cmd=hello'
|
|
|
|
200 Script output follows
|
|
|
|
|
2018-02-08 02:18:36 +03:00
|
|
|
capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream-preferred streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%2C03%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=*getflogheads getfile (glob)
|
2015-06-29 23:43:54 +03:00
|
|
|
|
|
|
|
$ get-with-headers.py localhost:$HGPORT '?cmd=this-command-does-not-exist' | head -n 1
|
|
|
|
400 no such method: this-command-does-not-exist
|
|
|
|
$ get-with-headers.py localhost:$HGPORT '?cmd=getfiles' | head -n 1
|
2015-06-30 18:04:47 +03:00
|
|
|
400 no such method: getfiles
|
2015-08-04 21:59:53 +03:00
|
|
|
|
|
|
|
Verify serving from a shallow clone doesn't allow for remotefile
|
|
|
|
fetches. This also serves to test the error handling for our batchable
|
|
|
|
getfile RPC.
|
|
|
|
|
|
|
|
$ cd shallow
|
2018-02-08 02:18:29 +03:00
|
|
|
$ hg serve -p 0 --port-file $TESTTMP/.port -d --pid-file=../hg2.pid -E ../error2.log
|
|
|
|
$ HGPORT1=`cat $TESTTMP/.port`
|
2015-08-04 21:59:53 +03:00
|
|
|
$ cd ..
|
|
|
|
$ cat hg2.pid >> $DAEMON_PIDS
|
|
|
|
|
|
|
|
This GET should work, because this server is serving master, which is
|
|
|
|
a full clone.
|
|
|
|
|
|
|
|
$ get-with-headers.py localhost:$HGPORT "$GET"
|
|
|
|
200 Script output follows
|
|
|
|
|
|
|
|
0\x00U\x00\x00\x00\xff (esc)
|
|
|
|
2\x00x (esc)
|
|
|
|
\x14\x06\xe7A\x18bv\x94&\x84\x17I\x1f\x01\x8aJ\x881R\xf0\x00\x01\x00\x14\xf0\x06\xb2\x92\xc1\xe31\x1f\xd0\xf1:\xe8;@\x9c\xaa\xe4\xa6\xd1\xfb4\x8c\x00 (no-eol) (esc)
|
|
|
|
|
|
|
|
This GET should fail using the in-band signalling mechanism, because
|
|
|
|
it's not a full clone. Note that it's also plausible for servers to
|
|
|
|
refuse to serve file contents for other reasons, like the file
|
|
|
|
contents not being visible to the current user.
|
|
|
|
|
|
|
|
$ get-with-headers.py localhost:$HGPORT1 "$GET"
|
|
|
|
200 Script output follows
|
|
|
|
|
|
|
|
1\x00cannot fetch remote files from shallow repo (no-eol) (esc)
|
|
|
|
|
2016-05-19 08:39:20 +03:00
|
|
|
Clones should work with httppostargs turned on
|
|
|
|
|
|
|
|
$ cd master
|
|
|
|
$ hg --config experimental.httppostargs=1 serve -p $HGPORT2 -d --pid-file=../hg3.pid -E ../error3.log
|
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
$ cat hg3.pid >> $DAEMON_PIDS
|
|
|
|
|
|
|
|
Clear filenode cache so we can test fetching with a modified batch size
|
|
|
|
$ rm -r $TESTTMP/hgcache
|
|
|
|
|
|
|
|
$ hgcloneshallow http://localhost:$HGPORT2/ shallow-postargs -q
|
|
|
|
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
|
|
|
|
|
|
|
|
All error logs should be empty:
|
2015-08-04 21:59:53 +03:00
|
|
|
$ cat error.log
|
|
|
|
$ cat error2.log
|
2016-05-19 08:39:20 +03:00
|
|
|
$ cat error3.log
|