tests/wireprotohelpers.sh
author Pulkit Goyal <7895pulkit@gmail.com>
Sat, 14 Apr 2018 01:59:55 +0530
changeset 37663 fc114a16a484
parent 37540 693cb3768943
child 37718 ad1c07008e0b
permissions -rw-r--r--
py3: use stringutil.forcebytestr() instead of str() We need to convert errors to bytes using stringutil.forcebytestr() Differential Revision: https://phab.mercurial-scm.org/D3324
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37482
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
HTTPV2=exp-http-v2-0001
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
MEDIATYPE=application/mercurial-exp-framing-0003
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
sendhttpraw() {
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
  hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT/
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
}
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
37483
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37482
diff changeset
     8
sendhttpv2peer() {
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37482
diff changeset
     9
  hg --verbose debugwireproto --peer http2 http://$LOCALIP:$HGPORT/
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37482
diff changeset
    10
}
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37482
diff changeset
    11
37482
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
cat > dummycommands.py << EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
from mercurial import (
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
    wireprototypes,
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
    wireproto,
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
)
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
@wireproto.wireprotocommand('customreadonly', permission='pull')
37540
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    19
def customreadonlyv1(repo, proto):
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    20
    return wireprototypes.bytesresponse(b'customreadonly bytes response')
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    21
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    22
@wireproto.wireprotocommand('customreadonly', permission='pull',
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    23
                            transportpolicy=wireproto.POLICY_V2_ONLY)
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    24
def customreadonlyv2(repo, proto):
37482
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    25
    return wireprototypes.bytesresponse(b'customreadonly bytes response')
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    27
@wireproto.wireprotocommand('customreadwrite', permission='push')
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
def customreadwrite(repo, proto):
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
    return wireprototypes.bytesresponse(b'customreadwrite bytes response')
37540
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    30
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    31
@wireproto.wireprotocommand('customreadwrite', permission='push',
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    32
                            transportpolicy=wireproto.POLICY_V2_ONLY)
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    33
def customreadwritev2(repo, proto):
693cb3768943 wireproto: make @wireprotocommand version 1 only by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37483
diff changeset
    34
    return wireprototypes.bytesresponse(b'customreadwrite bytes response')
37482
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
cat >> $HGRCPATH << EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
[extensions]
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
drawdag = $TESTDIR/drawdag.py
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    42
enabledummycommands() {
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    43
  cat >> $HGRCPATH << EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
[extensions]
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    45
dummycommands = $TESTTMP/dummycommands.py
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    47
}
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
enablehttpv2() {
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
  cat >> $1/.hg/hgrc << EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
[experimental]
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
web.apiserver = true
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
web.api.http-v2 = true
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
EOF
fa9faf58959d tests: extract wire protocol shell helpers to standalone file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
}