tests/test-ssh-proto.t
changeset 36528 72e487851a53
parent 36527 44dc34b8d17b
child 36530 bde0bd50f368
equal deleted inserted replaced
36527:44dc34b8d17b 36528:72e487851a53
    10   $ hg init server
    10   $ hg init server
    11   $ cd server
    11   $ cd server
    12   $ echo 0 > foo
    12   $ echo 0 > foo
    13   $ hg -q add foo
    13   $ hg -q add foo
    14   $ hg commit -m initial
    14   $ hg commit -m initial
       
    15 
       
    16 A no-op connection performs a handshake
       
    17 
       
    18   $ hg debugwireproto --localssh << EOF
       
    19   > EOF
       
    20   creating ssh peer from handshake results
       
    21 
       
    22 Raw peers don't perform any activity
       
    23 
       
    24   $ hg debugwireproto --localssh --peer raw << EOF
       
    25   > EOF
       
    26   using raw connection to peer
       
    27   $ hg debugwireproto --localssh --peer ssh1 << EOF
       
    28   > EOF
       
    29   creating ssh peer for wire protocol version 1
       
    30   $ hg debugwireproto --localssh --peer ssh2 << EOF
       
    31   > EOF
       
    32   creating ssh peer for wire protocol version 2
       
    33 
       
    34 Test a normal behaving server, for sanity
       
    35 
    15   $ cd ..
    36   $ cd ..
    16 
       
    17 Test a normal behaving server, for sanity
       
    18 
    37 
    19   $ hg --debug debugpeer ssh://user@dummy/server
    38   $ hg --debug debugpeer ssh://user@dummy/server
    20   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
    39   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
    21   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
    40   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
    22   devel-peer-request: hello
    41   devel-peer-request: hello
    31   local: no
    50   local: no
    32   pushable: yes
    51   pushable: yes
    33 
    52 
    34 Server should answer the "hello" command in isolation
    53 Server should answer the "hello" command in isolation
    35 
    54 
    36   $ hg -R server serve --stdio << EOF
    55   $ hg -R server debugwireproto --localssh --peer raw << EOF
    37   > hello
    56   > raw
    38   > EOF
    57   >     hello\n
    39   384
    58   > readline
    40   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
    59   > readline
       
    60   > EOF
       
    61   using raw connection to peer
       
    62   i> write(6) -> None:
       
    63   i>     hello\n
       
    64   o> readline() -> 4:
       
    65   o>     384\n
       
    66   o> readline() -> 384:
       
    67   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
    41 
    68 
    42 `hg debugserve --sshstdio` works
    69 `hg debugserve --sshstdio` works
    43 
    70 
    44   $ cd server
    71   $ cd server
    45   $ hg debugserve --sshstdio << EOF
    72   $ hg debugserve --sshstdio << EOF
    78 
   105 
    79 >=0.9.1 clients send a "hello" + "between" for the null range as part of handshake.
   106 >=0.9.1 clients send a "hello" + "between" for the null range as part of handshake.
    80 Server should reply with capabilities and should send "1\n\n" as a successful
   107 Server should reply with capabilities and should send "1\n\n" as a successful
    81 reply with empty response to the "between".
   108 reply with empty response to the "between".
    82 
   109 
    83   $ hg -R server serve --stdio << EOF
   110   $ hg -R server debugwireproto --localssh --peer raw << EOF
    84   > hello
   111   > raw
    85   > between
   112   >     hello\n
    86   > pairs 81
   113   > readline
    87   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   114   > readline
    88   > EOF
   115   > raw
    89   384
   116   >     between\n
    90   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   117   >     pairs 81\n
    91   1
   118   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
    92   
   119   > readline
       
   120   > readline
       
   121   > EOF
       
   122   using raw connection to peer
       
   123   i> write(6) -> None:
       
   124   i>     hello\n
       
   125   o> readline() -> 4:
       
   126   o>     384\n
       
   127   o> readline() -> 384:
       
   128   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   129   i> write(98) -> None:
       
   130   i>     between\n
       
   131   i>     pairs 81\n
       
   132   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   133   o> readline() -> 2:
       
   134   o>     1\n
       
   135   o> readline() -> 1:
       
   136   o>     \n
    93 
   137 
    94 SSH banner is not printed by default, ignored by clients
   138 SSH banner is not printed by default, ignored by clients
    95 
   139 
    96   $ SSHSERVERMODE=banner hg debugpeer ssh://user@dummy/server
   140   $ SSHSERVERMODE=banner hg debugpeer ssh://user@dummy/server
    97   url: ssh://user@dummy/server
   141   url: ssh://user@dummy/server
   125   local: no
   169   local: no
   126   pushable: yes
   170   pushable: yes
   127 
   171 
   128 And test the banner with the raw protocol
   172 And test the banner with the raw protocol
   129 
   173 
   130   $ SSHSERVERMODE=banner hg -R server serve --stdio << EOF
   174   $ SSHSERVERMODE=banner hg -R server debugwireproto --localssh --peer raw << EOF
   131   > hello
   175   > raw
   132   > between
   176   >     hello\n
   133   > pairs 81
   177   > readline
   134   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   178   > readline
   135   > EOF
   179   > readline
   136   banner: line 0
   180   > readline
   137   banner: line 1
   181   > readline
   138   banner: line 2
   182   > readline
   139   banner: line 3
   183   > readline
   140   banner: line 4
   184   > readline
   141   banner: line 5
   185   > readline
   142   banner: line 6
   186   > readline
   143   banner: line 7
   187   > readline
   144   banner: line 8
   188   > readline
   145   banner: line 9
   189   > raw
   146   384
   190   >     between\n
   147   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   191   >     pairs 81\n
   148   1
   192   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   149   
   193   > readline
       
   194   > readline
       
   195   > EOF
       
   196   using raw connection to peer
       
   197   i> write(6) -> None:
       
   198   i>     hello\n
       
   199   o> readline() -> 15:
       
   200   o>     banner: line 0\n
       
   201   o> readline() -> 15:
       
   202   o>     banner: line 1\n
       
   203   o> readline() -> 15:
       
   204   o>     banner: line 2\n
       
   205   o> readline() -> 15:
       
   206   o>     banner: line 3\n
       
   207   o> readline() -> 15:
       
   208   o>     banner: line 4\n
       
   209   o> readline() -> 15:
       
   210   o>     banner: line 5\n
       
   211   o> readline() -> 15:
       
   212   o>     banner: line 6\n
       
   213   o> readline() -> 15:
       
   214   o>     banner: line 7\n
       
   215   o> readline() -> 15:
       
   216   o>     banner: line 8\n
       
   217   o> readline() -> 15:
       
   218   o>     banner: line 9\n
       
   219   o> readline() -> 4:
       
   220   o>     384\n
       
   221   o> readline() -> 384:
       
   222   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   223   i> write(98) -> None:
       
   224   i>     between\n
       
   225   i>     pairs 81\n
       
   226   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   227   o> readline() -> 2:
       
   228   o>     1\n
       
   229   o> readline() -> 1:
       
   230   o>     \n
   150 
   231 
   151 Connecting to a <0.9.1 server that doesn't support the hello command.
   232 Connecting to a <0.9.1 server that doesn't support the hello command.
   152 The client should refuse, as we dropped support for connecting to such
   233 The client should refuse, as we dropped support for connecting to such
   153 servers.
   234 servers.
   154 
   235 
   165   abort: no suitable response from remote hg!
   246   abort: no suitable response from remote hg!
   166   [255]
   247   [255]
   167 
   248 
   168 Sending an unknown command to the server results in an empty response to that command
   249 Sending an unknown command to the server results in an empty response to that command
   169 
   250 
   170   $ hg -R server serve --stdio << EOF
   251   $ hg -R server debugwireproto --localssh --peer raw << EOF
   171   > pre-hello
   252   > raw
   172   > hello
   253   >     pre-hello\n
   173   > between
   254   > readline
   174   > pairs 81
   255   > raw
   175   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   256   >     hello\n
   176   > EOF
   257   > readline
   177   0
   258   > raw
   178   384
   259   >     between\n
   179   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   260   >     pairs 81\n
   180   1
   261   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   181   
   262   > readline
       
   263   > readline
       
   264   > EOF
       
   265   using raw connection to peer
       
   266   i> write(10) -> None:
       
   267   i>     pre-hello\n
       
   268   o> readline() -> 2:
       
   269   o>     0\n
       
   270   i> write(6) -> None:
       
   271   i>     hello\n
       
   272   o> readline() -> 4:
       
   273   o>     384\n
       
   274   i> write(98) -> None:
       
   275   i>     between\n
       
   276   i>     pairs 81\n
       
   277   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   278   o> readline() -> 384:
       
   279   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   280   o> readline() -> 2:
       
   281   o>     1\n
   182 
   282 
   183   $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-no-args --debug debugpeer ssh://user@dummy/server
   283   $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-no-args --debug debugpeer ssh://user@dummy/server
   184   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   284   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   185   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   285   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   186   sending no-args command
   286   sending no-args command
   197   local: no
   297   local: no
   198   pushable: yes
   298   pushable: yes
   199 
   299 
   200 Send multiple unknown commands before hello
   300 Send multiple unknown commands before hello
   201 
   301 
   202   $ hg -R server serve --stdio << EOF
   302   $ hg -R server debugwireproto --localssh --peer raw << EOF
   203   > unknown1
   303   > raw
   204   > unknown2
   304   >     unknown1\n
   205   > unknown3
   305   > readline
   206   > hello
   306   > raw
   207   > between
   307   >     unknown2\n
   208   > pairs 81
   308   > readline
   209   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   309   > raw
   210   > EOF
   310   >     unknown3\n
   211   0
   311   > readline
   212   0
   312   > raw
   213   0
   313   >     hello\n
   214   384
   314   > readline
   215   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   315   > readline
   216   1
   316   > raw
   217   
   317   >     between\n
       
   318   >     pairs 81\n
       
   319   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   320   > readline
       
   321   > readline
       
   322   > EOF
       
   323   using raw connection to peer
       
   324   i> write(9) -> None:
       
   325   i>     unknown1\n
       
   326   o> readline() -> 2:
       
   327   o>     0\n
       
   328   i> write(9) -> None:
       
   329   i>     unknown2\n
       
   330   o> readline() -> 2:
       
   331   o>     0\n
       
   332   i> write(9) -> None:
       
   333   i>     unknown3\n
       
   334   o> readline() -> 2:
       
   335   o>     0\n
       
   336   i> write(6) -> None:
       
   337   i>     hello\n
       
   338   o> readline() -> 4:
       
   339   o>     384\n
       
   340   o> readline() -> 384:
       
   341   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   342   i> write(98) -> None:
       
   343   i>     between\n
       
   344   i>     pairs 81\n
       
   345   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   346   o> readline() -> 2:
       
   347   o>     1\n
       
   348   o> readline() -> 1:
       
   349   o>     \n
   218 
   350 
   219   $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-multiple-no-args --debug debugpeer ssh://user@dummy/server
   351   $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-multiple-no-args --debug debugpeer ssh://user@dummy/server
   220   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   352   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   221   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   353   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   222   sending unknown1 command
   354   sending unknown1 command
   237   local: no
   369   local: no
   238   pushable: yes
   370   pushable: yes
   239 
   371 
   240 Send an unknown command before hello that has arguments
   372 Send an unknown command before hello that has arguments
   241 
   373 
   242   $ hg -R server serve --stdio << EOF
   374   $ cd server
   243   > with-args
   375 
   244   > foo 13
   376   $ hg debugwireproto --localssh --peer raw << EOF
   245   > value for foo
   377   > raw
   246   > bar 13
   378   >     with-args\n
   247   > value for bar
   379   >     foo 13\n
   248   > hello
   380   >     value for foo\n
   249   > between
   381   >     bar 13\n
   250   > pairs 81
   382   >     value for bar\n
   251   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   383   > readline
   252   > EOF
   384   > readline
   253   0
   385   > readline
   254   0
   386   > readline
   255   0
   387   > readline
   256   0
   388   > raw
   257   0
   389   >     hello\n
   258   384
   390   > readline
   259   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   391   > readline
   260   1
   392   > raw
   261   
   393   >     between\n
       
   394   >     pairs 81\n
       
   395   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   396   > readline
       
   397   > readline
       
   398   > EOF
       
   399   using raw connection to peer
       
   400   i> write(52) -> None:
       
   401   i>     with-args\n
       
   402   i>     foo 13\n
       
   403   i>     value for foo\n
       
   404   i>     bar 13\n
       
   405   i>     value for bar\n
       
   406   o> readline() -> 2:
       
   407   o>     0\n
       
   408   o> readline() -> 2:
       
   409   o>     0\n
       
   410   o> readline() -> 2:
       
   411   o>     0\n
       
   412   o> readline() -> 2:
       
   413   o>     0\n
       
   414   o> readline() -> 2:
       
   415   o>     0\n
       
   416   i> write(6) -> None:
       
   417   i>     hello\n
       
   418   o> readline() -> 4:
       
   419   o>     384\n
       
   420   o> readline() -> 384:
       
   421   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   422   i> write(98) -> None:
       
   423   i>     between\n
       
   424   i>     pairs 81\n
       
   425   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   426   o> readline() -> 2:
       
   427   o>     1\n
       
   428   o> readline() -> 1:
       
   429   o>     \n
   262 
   430 
   263 Send an unknown command having an argument that looks numeric
   431 Send an unknown command having an argument that looks numeric
   264 
   432 
   265   $ hg -R server serve --stdio << EOF
   433   $ hg debugwireproto --localssh --peer raw << EOF
   266   > unknown
   434   > raw
   267   > foo 1
   435   >     unknown\n
   268   > 0
   436   >     foo 1\n
   269   > hello
   437   >     0\n
   270   > between
   438   > readline
   271   > pairs 81
   439   > readline
   272   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   440   > readline
   273   > EOF
   441   > raw
   274   0
   442   >     hello\n
   275   0
   443   > readline
   276   0
   444   > readline
   277   384
   445   > raw
   278   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   446   >     between\n
   279   1
   447   >     pairs 81\n
   280   
   448   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   281 
   449   > readline
   282   $ hg -R server serve --stdio << EOF
   450   > readline
   283   > unknown
   451   > EOF
   284   > foo 1
   452   using raw connection to peer
   285   > 1
   453   i> write(16) -> None:
   286   > hello
   454   i>     unknown\n
   287   > between
   455   i>     foo 1\n
   288   > pairs 81
   456   i>     0\n
   289   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   457   o> readline() -> 2:
   290   > EOF
   458   o>     0\n
   291   0
   459   o> readline() -> 2:
   292   0
   460   o>     0\n
   293   0
   461   o> readline() -> 2:
   294   384
   462   o>     0\n
   295   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   463   i> write(6) -> None:
   296   1
   464   i>     hello\n
   297   
   465   o> readline() -> 4:
       
   466   o>     384\n
       
   467   o> readline() -> 384:
       
   468   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   469   i> write(98) -> None:
       
   470   i>     between\n
       
   471   i>     pairs 81\n
       
   472   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   473   o> readline() -> 2:
       
   474   o>     1\n
       
   475   o> readline() -> 1:
       
   476   o>     \n
       
   477 
       
   478   $ hg debugwireproto --localssh --peer raw << EOF
       
   479   > raw
       
   480   >     unknown\n
       
   481   >     foo 1\n
       
   482   >     1\n
       
   483   > readline
       
   484   > readline
       
   485   > readline
       
   486   > raw
       
   487   >     hello\n
       
   488   > readline
       
   489   > readline
       
   490   > raw
       
   491   >     between\n
       
   492   >     pairs 81\n
       
   493   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   494   > readline
       
   495   > readline
       
   496   > EOF
       
   497   using raw connection to peer
       
   498   i> write(16) -> None:
       
   499   i>     unknown\n
       
   500   i>     foo 1\n
       
   501   i>     1\n
       
   502   o> readline() -> 2:
       
   503   o>     0\n
       
   504   o> readline() -> 2:
       
   505   o>     0\n
       
   506   o> readline() -> 2:
       
   507   o>     0\n
       
   508   i> write(6) -> None:
       
   509   i>     hello\n
       
   510   o> readline() -> 4:
       
   511   o>     384\n
       
   512   o> readline() -> 384:
       
   513   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   514   i> write(98) -> None:
       
   515   i>     between\n
       
   516   i>     pairs 81\n
       
   517   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   518   o> readline() -> 2:
       
   519   o>     1\n
       
   520   o> readline() -> 1:
       
   521   o>     \n
   298 
   522 
   299 When sending a dict argument value, it is serialized to
   523 When sending a dict argument value, it is serialized to
   300 "<arg> <item count>" followed by "<key> <len>\n<value>" for each item
   524 "<arg> <item count>" followed by "<key> <len>\n<value>" for each item
   301 in the dict.
   525 in the dict.
   302 
   526 
   303 Dictionary value for unknown command
   527 Dictionary value for unknown command
   304 
   528 
   305   $ hg -R server serve --stdio << EOF
   529   $ hg debugwireproto --localssh --peer raw << EOF
   306   > unknown
   530   > raw
   307   > dict 3
   531   >     unknown\n
   308   > key1 3
   532   >     dict 3\n
   309   > foo
   533   >     key1 3\n
   310   > key2 3
   534   >     foo\n
   311   > bar
   535   >     key2 3\n
   312   > key3 3
   536   >     bar\n
   313   > baz
   537   >     key3 3\n
   314   > hello
   538   >     baz\n
   315   > EOF
   539   > readline
   316   0
   540   > readline
   317   0
   541   > readline
   318   0
   542   > readline
   319   0
   543   > readline
   320   0
   544   > readline
   321   0
   545   > readline
   322   0
   546   > readline
   323   0
   547   > raw
   324   384
   548   >     hello\n
   325   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   549   > readline
       
   550   > readline
       
   551   > EOF
       
   552   using raw connection to peer
       
   553   i> write(48) -> None:
       
   554   i>     unknown\n
       
   555   i>     dict 3\n
       
   556   i>     key1 3\n
       
   557   i>     foo\n
       
   558   i>     key2 3\n
       
   559   i>     bar\n
       
   560   i>     key3 3\n
       
   561   i>     baz\n
       
   562   o> readline() -> 2:
       
   563   o>     0\n
       
   564   o> readline() -> 2:
       
   565   o>     0\n
       
   566   o> readline() -> 2:
       
   567   o>     0\n
       
   568   o> readline() -> 2:
       
   569   o>     0\n
       
   570   o> readline() -> 2:
       
   571   o>     0\n
       
   572   o> readline() -> 2:
       
   573   o>     0\n
       
   574   o> readline() -> 2:
       
   575   o>     0\n
       
   576   o> readline() -> 2:
       
   577   o>     0\n
       
   578   i> write(6) -> None:
       
   579   i>     hello\n
       
   580   o> readline() -> 4:
       
   581   o>     384\n
       
   582   o> readline() -> 384:
       
   583   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
   326 
   584 
   327 Incomplete dictionary send
   585 Incomplete dictionary send
   328 
   586 
   329   $ hg -R server serve --stdio << EOF
   587   $ hg debugwireproto --localssh --peer raw << EOF
   330   > unknown
   588   > raw
   331   > dict 3
   589   >     unknown\n
   332   > key1 3
   590   >     dict 3\n
   333   > foo
   591   >     key1 3\n
   334   > EOF
   592   >     foo\n
   335   0
   593   > readline
   336   0
   594   > readline
   337   0
   595   > readline
   338   0
   596   > readline
       
   597   > EOF
       
   598   using raw connection to peer
       
   599   i> write(26) -> None:
       
   600   i>     unknown\n
       
   601   i>     dict 3\n
       
   602   i>     key1 3\n
       
   603   i>     foo\n
       
   604   o> readline() -> 2:
       
   605   o>     0\n
       
   606   o> readline() -> 2:
       
   607   o>     0\n
       
   608   o> readline() -> 2:
       
   609   o>     0\n
       
   610   o> readline() -> 2:
       
   611   o>     0\n
   339 
   612 
   340 Incomplete value send
   613 Incomplete value send
   341 
   614 
   342   $ hg -R server serve --stdio << EOF
   615   $ hg debugwireproto --localssh --peer raw << EOF
   343   > unknown
   616   > raw
   344   > dict 3
   617   >     unknown\n
   345   > key1 3
   618   >     dict 3\n
   346   > fo
   619   >     key1 3\n
   347   > EOF
   620   >     fo
   348   0
   621   > readline
   349   0
   622   > readline
   350   0
   623   > readline
   351   0
   624   > EOF
       
   625   using raw connection to peer
       
   626   i> write(24) -> None:
       
   627   i>     unknown\n
       
   628   i>     dict 3\n
       
   629   i>     key1 3\n
       
   630   i>     fo
       
   631   o> readline() -> 2:
       
   632   o>     0\n
       
   633   o> readline() -> 2:
       
   634   o>     0\n
       
   635   o> readline() -> 2:
       
   636   o>     0\n
   352 
   637 
   353 Send a command line with spaces
   638 Send a command line with spaces
   354 
   639 
   355   $ hg -R server serve --stdio << EOF
   640   $ hg debugwireproto --localssh --peer raw << EOF
   356   > unknown withspace
   641   > raw
   357   > hello
   642   >     unknown withspace\n
   358   > between
   643   > readline
   359   > pairs 81
   644   > raw
   360   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   645   >     hello\n
   361   > EOF
   646   > readline
   362   0
   647   > readline
   363   384
   648   > raw
   364   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   649   >     between\n
   365   1
   650   >     pairs 81\n
   366   
   651   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   367 
   652   > readline
   368   $ hg -R server serve --stdio << EOF
   653   > readline
   369   > unknown with multiple spaces
   654   > EOF
   370   > hello
   655   using raw connection to peer
   371   > between
   656   i> write(18) -> None:
   372   > pairs 81
   657   i>     unknown withspace\n
   373   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   658   o> readline() -> 2:
   374   > EOF
   659   o>     0\n
   375   0
   660   i> write(6) -> None:
   376   384
   661   i>     hello\n
   377   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   662   o> readline() -> 4:
   378   1
   663   o>     384\n
   379   
   664   o> readline() -> 384:
   380 
   665   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
   381   $ hg -R server serve --stdio << EOF
   666   i> write(98) -> None:
   382   > unknown with spaces
   667   i>     between\n
   383   > key 10
   668   i>     pairs 81\n
   384   > some value
   669   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   385   > hello
   670   o> readline() -> 2:
   386   > between
   671   o>     1\n
   387   > pairs 81
   672   o> readline() -> 1:
   388   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   673   o>     \n
   389   > EOF
   674 
   390   0
   675   $ hg debugwireproto --localssh --peer raw << EOF
   391   0
   676   > raw
   392   0
   677   >     unknown with multiple spaces\n
   393   384
   678   > readline
   394   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   679   > raw
   395   1
   680   >     hello\n
   396   
   681   > readline
       
   682   > readline
       
   683   > raw
       
   684   >     between\n
       
   685   >     pairs 81\n
       
   686   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   687   > readline
       
   688   > EOF
       
   689   using raw connection to peer
       
   690   i> write(29) -> None:
       
   691   i>     unknown with multiple spaces\n
       
   692   o> readline() -> 2:
       
   693   o>     0\n
       
   694   i> write(6) -> None:
       
   695   i>     hello\n
       
   696   o> readline() -> 4:
       
   697   o>     384\n
       
   698   o> readline() -> 384:
       
   699   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   700   i> write(98) -> None:
       
   701   i>     between\n
       
   702   i>     pairs 81\n
       
   703   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   704   o> readline() -> 2:
       
   705   o>     1\n
       
   706 
       
   707   $ hg debugwireproto --localssh --peer raw << EOF
       
   708   > raw
       
   709   >     unknown with spaces\n
       
   710   >     key 10\n
       
   711   >     some value\n
       
   712   > readline
       
   713   > readline
       
   714   > readline
       
   715   > raw
       
   716   >     hello\n
       
   717   > readline
       
   718   > readline
       
   719   > raw
       
   720   >     between\n
       
   721   >     pairs 81\n
       
   722   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   723   > readline
       
   724   > readline
       
   725   > EOF
       
   726   using raw connection to peer
       
   727   i> write(38) -> None:
       
   728   i>     unknown with spaces\n
       
   729   i>     key 10\n
       
   730   i>     some value\n
       
   731   o> readline() -> 2:
       
   732   o>     0\n
       
   733   o> readline() -> 2:
       
   734   o>     0\n
       
   735   o> readline() -> 2:
       
   736   o>     0\n
       
   737   i> write(6) -> None:
       
   738   i>     hello\n
       
   739   o> readline() -> 4:
       
   740   o>     384\n
       
   741   o> readline() -> 384:
       
   742   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   743   i> write(98) -> None:
       
   744   i>     between\n
       
   745   i>     pairs 81\n
       
   746   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   747   o> readline() -> 2:
       
   748   o>     1\n
       
   749   o> readline() -> 1:
       
   750   o>     \n
   397 
   751 
   398 Send an unknown command after the "between"
   752 Send an unknown command after the "between"
   399 
   753 
   400   $ hg -R server serve --stdio << EOF
   754   $ hg debugwireproto --localssh --peer raw << EOF
   401   > hello
   755   > raw
   402   > between
   756   >     hello\n
   403   > pairs 81
   757   > readline
   404   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
   758   > readline
   405   > EOF
   759   > raw
   406   384
   760   >     between\n
   407   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   761   >     pairs 81\n
   408   1
   762   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
   409   
   763   > readline
   410   0
   764   > readline
       
   765   > EOF
       
   766   using raw connection to peer
       
   767   i> write(6) -> None:
       
   768   i>     hello\n
       
   769   o> readline() -> 4:
       
   770   o>     384\n
       
   771   o> readline() -> 384:
       
   772   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   773   i> write(105) -> None:
       
   774   i>     between\n
       
   775   i>     pairs 81\n
       
   776   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
       
   777   o> readline() -> 2:
       
   778   o>     1\n
       
   779   o> readline() -> 1:
       
   780   o>     \n
   411 
   781 
   412 And one with arguments
   782 And one with arguments
   413 
   783 
   414   $ hg -R server serve --stdio << EOF
   784   $ hg debugwireproto --localssh --peer raw << EOF
   415   > hello
   785   > raw
   416   > between
   786   >     hello\n
   417   > pairs 81
   787   >     between\n
   418   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
   788   >     pairs 81\n
   419   > foo 5
   789   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   420   > value
   790   > readline
   421   > bar 3
   791   > readline
   422   > baz
   792   > readline
   423   > EOF
   793   > readline
   424   384
   794   > raw
   425   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   795   >     unknown\n
   426   1
   796   >     foo 5\n
   427   
   797   >     \nvalue\n
   428   0
   798   >     bar 3\n
   429   0
   799   >     baz\n
   430   0
   800   > readline
   431   0
   801   > readline
   432   0
   802   > readline
       
   803   > EOF
       
   804   using raw connection to peer
       
   805   i> write(104) -> None:
       
   806   i>     hello\n
       
   807   i>     between\n
       
   808   i>     pairs 81\n
       
   809   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   810   o> readline() -> 4:
       
   811   o>     384\n
       
   812   o> readline() -> 384:
       
   813   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   814   o> readline() -> 2:
       
   815   o>     1\n
       
   816   o> readline() -> 1:
       
   817   o>     \n
       
   818   i> write(31) -> None:
       
   819   i>     unknown\n
       
   820   i>     foo 5\n
       
   821   i>     \n
       
   822   i>     value\n
       
   823   i>     bar 3\n
       
   824   i>     baz\n
       
   825   o> readline() -> 2:
       
   826   o>     0\n
       
   827   o> readline() -> 2:
       
   828   o>     0\n
       
   829   o> readline() -> 0: 
   433 
   830 
   434 Send a valid command before the handshake
   831 Send a valid command before the handshake
   435 
   832 
   436   $ hg -R server serve --stdio << EOF
   833   $ hg debugwireproto --localssh --peer raw << EOF
   437   > heads
   834   > raw
   438   > hello
   835   >     heads\n
   439   > between
   836   > readline
   440   > pairs 81
   837   > raw
   441   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   838   >     hello\n
   442   > EOF
   839   >     between\n
   443   41
   840   >     pairs 81\n
   444   68986213bd4485ea51533535e3fc9e78007a711f
   841   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   445   384
   842   > readline
   446   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   843   > readline
   447   1
   844   > readline
   448   
   845   > readline
       
   846   > EOF
       
   847   using raw connection to peer
       
   848   i> write(6) -> None:
       
   849   i>     heads\n
       
   850   o> readline() -> 3:
       
   851   o>     41\n
       
   852   i> write(104) -> None:
       
   853   i>     hello\n
       
   854   i>     between\n
       
   855   i>     pairs 81\n
       
   856   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   857   o> readline() -> 41:
       
   858   o>     68986213bd4485ea51533535e3fc9e78007a711f\n
       
   859   o> readline() -> 4:
       
   860   o>     384\n
       
   861   o> readline() -> 384:
       
   862   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   863   o> readline() -> 2:
       
   864   o>     1\n
   449 
   865 
   450 And a variation that doesn't send the between command
   866 And a variation that doesn't send the between command
   451 
   867 
   452   $ hg -R server serve --stdio << EOF
   868   $ hg debugwireproto --localssh --peer raw << EOF
   453   > heads
   869   > raw
   454   > hello
   870   >     heads\n
   455   > EOF
   871   > readline
   456   41
   872   > raw
   457   68986213bd4485ea51533535e3fc9e78007a711f
   873   >     hello\n
   458   384
   874   > readline
   459   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   875   > readline
       
   876   > EOF
       
   877   using raw connection to peer
       
   878   i> write(6) -> None:
       
   879   i>     heads\n
       
   880   o> readline() -> 3:
       
   881   o>     41\n
       
   882   i> write(6) -> None:
       
   883   i>     hello\n
       
   884   o> readline() -> 41:
       
   885   o>     68986213bd4485ea51533535e3fc9e78007a711f\n
       
   886   o> readline() -> 4:
       
   887   o>     384\n
   460 
   888 
   461 Send an upgrade request to a server that doesn't support that command
   889 Send an upgrade request to a server that doesn't support that command
   462 
   890 
   463   $ hg -R server serve --stdio << EOF
   891   $ hg debugwireproto --localssh --peer raw << EOF
   464   > upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=irrelevant1%2Cirrelevant2
   892   > raw
   465   > hello
   893   >     upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=irrelevant1%2Cirrelevant2\n
   466   > between
   894   > readline
   467   > pairs 81
   895   > raw
   468   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   896   >     hello\n
   469   > EOF
   897   >     between\n
   470   0
   898   >     pairs 81\n
   471   384
   899   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   472   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   900   > readline
   473   1
   901   > readline
   474   
   902   > readline
       
   903   > readline
       
   904   > EOF
       
   905   using raw connection to peer
       
   906   i> write(77) -> None:
       
   907   i>     upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=irrelevant1%2Cirrelevant2\n
       
   908   o> readline() -> 2:
       
   909   o>     0\n
       
   910   i> write(104) -> None:
       
   911   i>     hello\n
       
   912   i>     between\n
       
   913   i>     pairs 81\n
       
   914   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   915   o> readline() -> 4:
       
   916   o>     384\n
       
   917   o> readline() -> 384:
       
   918   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   919   o> readline() -> 2:
       
   920   o>     1\n
       
   921   o> readline() -> 1:
       
   922   o>     \n
       
   923 
       
   924   $ cd ..
   475 
   925 
   476   $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
   926   $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
   477   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   927   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   478   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   928   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   479   sending upgrade request: * proto=exp-ssh-v2-0001 (glob)
   929   sending upgrade request: * proto=exp-ssh-v2-0001 (glob)
   498   > sshserver.support-v2 = true
   948   > sshserver.support-v2 = true
   499   > EOF
   949   > EOF
   500 
   950 
   501 Send an upgrade request to a server that supports upgrade
   951 Send an upgrade request to a server that supports upgrade
   502 
   952 
   503   >>> with open('payload', 'wb') as fh:
   953   $ cd server
   504   ...     fh.write(b'upgrade this-is-some-token proto=exp-ssh-v2-0001\n')
   954 
   505   ...     fh.write(b'hello\n')
   955   $ hg debugwireproto --localssh --peer raw << EOF
   506   ...     fh.write(b'between\n')
   956   > raw
   507   ...     fh.write(b'pairs 81\n')
   957   >     upgrade this-is-some-token proto=exp-ssh-v2-0001\n
   508   ...     fh.write(b'0000000000000000000000000000000000000000-0000000000000000000000000000000000000000')
   958   >     hello\n
   509 
   959   >     between\n
   510   $ hg -R server serve --stdio < payload
   960   >     pairs 81\n
   511   upgraded this-is-some-token exp-ssh-v2-0001
   961   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   512   383
   962   > readline
   513   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
   963   > readline
       
   964   > readline
       
   965   > EOF
       
   966   using raw connection to peer
       
   967   i> write(153) -> None:
       
   968   i>     upgrade this-is-some-token proto=exp-ssh-v2-0001\n
       
   969   i>     hello\n
       
   970   i>     between\n
       
   971   i>     pairs 81\n
       
   972   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
   973   o> readline() -> 44:
       
   974   o>     upgraded this-is-some-token exp-ssh-v2-0001\n
       
   975   o> readline() -> 4:
       
   976   o>     383\n
       
   977   o> readline() -> 384:
       
   978   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
   979 
       
   980   $ cd ..
   514 
   981 
   515   $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
   982   $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
   516   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   983   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
   517   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   984   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
   518   sending upgrade request: * proto=exp-ssh-v2-0001 (glob)
   985   sending upgrade request: * proto=exp-ssh-v2-0001 (glob)
   576       http
  1043       http
   577       https
  1044       https
   578 
  1045 
   579 Command after upgrade to version 2 is processed
  1046 Command after upgrade to version 2 is processed
   580 
  1047 
   581   >>> with open('payload', 'wb') as fh:
  1048   $ cd server
   582   ...     fh.write(b'upgrade this-is-some-token proto=exp-ssh-v2-0001\n')
  1049 
   583   ...     fh.write(b'hello\n')
  1050   $ hg debugwireproto --localssh --peer raw << EOF
   584   ...     fh.write(b'between\n')
  1051   > raw
   585   ...     fh.write(b'pairs 81\n')
  1052   >      upgrade this-is-some-token proto=exp-ssh-v2-0001\n
   586   ...     fh.write(b'0000000000000000000000000000000000000000-0000000000000000000000000000000000000000')
  1053   >      hello\n
   587   ...     fh.write(b'hello\n')
  1054   >      between\n
   588   $ hg -R server serve --stdio < payload
  1055   >      pairs 81\n
   589   upgraded this-is-some-token exp-ssh-v2-0001
  1056   >      0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   590   383
  1057   > readline
   591   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
  1058   > readline
   592   384
  1059   > readline
   593   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
  1060   > raw
       
  1061   >      hello\n
       
  1062   > readline
       
  1063   > readline
       
  1064   > EOF
       
  1065   using raw connection to peer
       
  1066   i> write(153) -> None:
       
  1067   i>     upgrade this-is-some-token proto=exp-ssh-v2-0001\n
       
  1068   i>     hello\n
       
  1069   i>     between\n
       
  1070   i>     pairs 81\n
       
  1071   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
  1072   o> readline() -> 44:
       
  1073   o>     upgraded this-is-some-token exp-ssh-v2-0001\n
       
  1074   o> readline() -> 4:
       
  1075   o>     383\n
       
  1076   o> readline() -> 384:
       
  1077   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
  1078   i> write(6) -> None:
       
  1079   i>     hello\n
       
  1080   o> readline() -> 4:
       
  1081   o>     384\n
       
  1082   o> readline() -> 384:
       
  1083   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
   594 
  1084 
   595 Multiple upgrades is not allowed
  1085 Multiple upgrades is not allowed
   596 
  1086 
   597   >>> with open('payload', 'wb') as fh:
  1087   $ hg debugwireproto --localssh --peer raw << EOF
   598   ...     fh.write(b'upgrade this-is-some-token proto=exp-ssh-v2-0001\n')
  1088   > raw
   599   ...     fh.write(b'hello\n')
  1089   >     upgrade this-is-some-token proto=exp-ssh-v2-0001\n
   600   ...     fh.write(b'between\n')
  1090   >     hello\n
   601   ...     fh.write(b'pairs 81\n')
  1091   >     between\n
   602   ...     fh.write(b'0000000000000000000000000000000000000000-0000000000000000000000000000000000000000')
  1092   >     pairs 81\n
   603   ...     fh.write(b'upgrade another-token proto=irrelevant\n')
  1093   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   604   ...     fh.write(b'hello\n')
  1094   > readline
   605   $ hg -R server serve --stdio < payload
  1095   > readline
   606   upgraded this-is-some-token exp-ssh-v2-0001
  1096   > readline
   607   383
  1097   > raw
   608   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
  1098   >     upgrade another-token proto=irrelevant\n
   609   cannot upgrade protocols multiple times
  1099   >     hello\n
   610   -
  1100   > readline
   611   
  1101   > readavailable
       
  1102   > EOF
       
  1103   using raw connection to peer
       
  1104   i> write(153) -> None:
       
  1105   i>     upgrade this-is-some-token proto=exp-ssh-v2-0001\n
       
  1106   i>     hello\n
       
  1107   i>     between\n
       
  1108   i>     pairs 81\n
       
  1109   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
  1110   o> readline() -> 44:
       
  1111   o>     upgraded this-is-some-token exp-ssh-v2-0001\n
       
  1112   o> readline() -> 4:
       
  1113   o>     383\n
       
  1114   o> readline() -> 384:
       
  1115   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
  1116   i> write(45) -> None:
       
  1117   i>     upgrade another-token proto=irrelevant\n
       
  1118   i>     hello\n
       
  1119   o> readline() -> 1:
       
  1120   o>     \n
       
  1121   e> read(-1) -> 42:
       
  1122   e>     cannot upgrade protocols multiple times\n
       
  1123   e>     -\n
   612 
  1124 
   613 Malformed upgrade request line (not exactly 3 space delimited tokens)
  1125 Malformed upgrade request line (not exactly 3 space delimited tokens)
   614 
  1126 
   615   $ hg -R server serve --stdio << EOF
  1127   $ hg debugwireproto --localssh --peer raw << EOF
   616   > upgrade
  1128   > raw
   617   > EOF
  1129   >     upgrade\n
   618   0
  1130   > readline
   619 
  1131   > EOF
   620   $ hg -R server serve --stdio << EOF
  1132   using raw connection to peer
   621   > upgrade token
  1133   i> write(8) -> None:
   622   > EOF
  1134   i>     upgrade\n
   623   0
  1135   o> readline() -> 2:
   624 
  1136   o>     0\n
   625   $ hg -R server serve --stdio << EOF
  1137 
   626   > upgrade token foo=bar extra-token
  1138   $ hg debugwireproto --localssh --peer raw << EOF
   627   > EOF
  1139   > raw
   628   0
  1140   >     upgrade token\n
       
  1141   > readline
       
  1142   > EOF
       
  1143   using raw connection to peer
       
  1144   i> write(14) -> None:
       
  1145   i>     upgrade token\n
       
  1146   o> readline() -> 2:
       
  1147   o>     0\n
       
  1148 
       
  1149   $ hg debugwireproto --localssh --peer raw << EOF
       
  1150   > raw
       
  1151   >     upgrade token foo=bar extra-token\n
       
  1152   > readline
       
  1153   > EOF
       
  1154   using raw connection to peer
       
  1155   i> write(34) -> None:
       
  1156   i>     upgrade token foo=bar extra-token\n
       
  1157   o> readline() -> 2:
       
  1158   o>     0\n
   629 
  1159 
   630 Upgrade request to unsupported protocol is ignored
  1160 Upgrade request to unsupported protocol is ignored
   631 
  1161 
   632   $ hg -R server serve --stdio << EOF
  1162   $ hg debugwireproto --localssh --peer raw << EOF
   633   > upgrade this-is-some-token proto=unknown1,unknown2
  1163   > raw
   634   > hello
  1164   >     upgrade this-is-some-token proto=unknown1,unknown2\n
   635   > between
  1165   > readline
   636   > pairs 81
  1166   > raw
   637   > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
  1167   >     hello\n
   638   > EOF
  1168   > readline
   639   0
  1169   > readline
   640   384
  1170   > raw
   641   capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
  1171   >     between\n
   642   1
  1172   >     pairs 81\n
   643   
  1173   >     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
  1174   > readline
       
  1175   > readline
       
  1176   > EOF
       
  1177   using raw connection to peer
       
  1178   i> write(51) -> None:
       
  1179   i>     upgrade this-is-some-token proto=unknown1,unknown2\n
       
  1180   o> readline() -> 2:
       
  1181   o>     0\n
       
  1182   i> write(6) -> None:
       
  1183   i>     hello\n
       
  1184   o> readline() -> 4:
       
  1185   o>     384\n
       
  1186   o> readline() -> 384:
       
  1187   o>     capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
       
  1188   i> write(98) -> None:
       
  1189   i>     between\n
       
  1190   i>     pairs 81\n
       
  1191   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
       
  1192   o> readline() -> 2:
       
  1193   o>     1\n
       
  1194   o> readline() -> 1:
       
  1195   o>     \n
   644 
  1196 
   645 Upgrade request must be followed by hello + between
  1197 Upgrade request must be followed by hello + between
   646 
  1198 
   647   $ hg -R server serve --stdio << EOF
  1199   $ hg debugwireproto --localssh --peer raw << EOF
   648   > upgrade token proto=exp-ssh-v2-0001
  1200   > raw
   649   > invalid
  1201   >     upgrade token proto=exp-ssh-v2-0001\n
   650   > EOF
  1202   >     invalid\n
   651   malformed handshake protocol: missing hello
  1203   > readline
   652   -
  1204   > readavailable
   653   
  1205   > EOF
   654 
  1206   using raw connection to peer
   655   $ hg -R server serve --stdio << EOF
  1207   i> write(44) -> None:
   656   > upgrade token proto=exp-ssh-v2-0001
  1208   i>     upgrade token proto=exp-ssh-v2-0001\n
   657   > hello
  1209   i>     invalid\n
   658   > invalid
  1210   o> readline() -> 1:
   659   > EOF
  1211   o>     \n
   660   malformed handshake protocol: missing between
  1212   e> read(-1) -> 46:
   661   -
  1213   e>     malformed handshake protocol: missing hello\n
   662   
  1214   e>     -\n
   663 
  1215 
   664   $ hg -R server serve --stdio << EOF
  1216   $ hg debugwireproto --localssh --peer raw << EOF
   665   > upgrade token proto=exp-ssh-v2-0001
  1217   > raw
   666   > hello
  1218   >     upgrade token proto=exp-ssh-v2-0001\n
   667   > between
  1219   >     hello\n
   668   > invalid
  1220   >     invalid\n
   669   > EOF
  1221   > readline
   670   malformed handshake protocol: missing pairs 81
  1222   > readavailable
   671   -
  1223   > EOF
   672   
  1224   using raw connection to peer
       
  1225   i> write(50) -> None:
       
  1226   i>     upgrade token proto=exp-ssh-v2-0001\n
       
  1227   i>     hello\n
       
  1228   i>     invalid\n
       
  1229   o> readline() -> 1:
       
  1230   o>     \n
       
  1231   e> read(-1) -> 48:
       
  1232   e>     malformed handshake protocol: missing between\n
       
  1233   e>     -\n
       
  1234 
       
  1235   $ hg debugwireproto --localssh --peer raw << EOF
       
  1236   > raw
       
  1237   >     upgrade token proto=exp-ssh-v2-0001\n
       
  1238   >     hello\n
       
  1239   >     between\n
       
  1240   >     invalid\n
       
  1241   > readline
       
  1242   > readavailable
       
  1243   > EOF
       
  1244   using raw connection to peer
       
  1245   i> write(58) -> None:
       
  1246   i>     upgrade token proto=exp-ssh-v2-0001\n
       
  1247   i>     hello\n
       
  1248   i>     between\n
       
  1249   i>     invalid\n
       
  1250   o> readline() -> 1:
       
  1251   o>     \n
       
  1252   e> read(-1) -> 49:
       
  1253   e>     malformed handshake protocol: missing pairs 81\n
       
  1254   e>     -\n