D1944: wireproto: provide accessors for client capabilities

2018-04-06 Thread joerg.sonnenberger (Joerg Sonnenberger)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGafcfdf53e4b5: wireproto: provide accessors for client 
capabilities (authored by joerg.sonnenberger, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1944?vs=7705=7786

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

AFFECTED FILES
  mercurial/help/internals/wireprotocol.txt
  mercurial/sshpeer.py
  mercurial/wireproto.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py
  tests/test-debugcommands.t
  tests/test-ssh-bundle1.t
  tests/test-ssh-proto-unbundle.t
  tests/test-ssh-proto.t
  tests/test-ssh.t

CHANGE DETAILS

diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -495,10 +495,13 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403 (sshv1 !)
+  remote: 413 (sshv1 !)
   protocol upgraded to exp-ssh-v2-0001 (sshv2 !)
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1 (sshv1 !)
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   query 1; heads
   devel-peer-request: batched-content
   devel-peer-request:- heads (0 arguments)
diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -63,9 +63,12 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -82,43 +85,43 @@
   i> write(6) -> 6:
   i> hello\n
   o> readline() -> 4:
-  o> 403\n
-  o> readline() -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o> 413\n
+  o> readline() -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
 
 `hg debugserve --sshstdio` works
 
   $ cd server
   $ hg debugserve --sshstdio << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
 
 I/O logging works
 
   $ hg debugserve --sshstdio --logiofd 1 << EOF
   > hello
   > EOF
   o> write(4) -> 4:
-  o> 403\n
-  o> write(403) -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o> 413\n
+  o> write(413) -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> flush() -> None
 
   $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset 

D1944: wireproto: provide accessors for client capabilities

2018-04-06 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  This looks great! It adds some much needed parity between the existing SSH 
and HTTP transports.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

To: joerg.sonnenberger, #hg-reviewers, indygreg
Cc: indygreg, mharbison72, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1944: wireproto: provide accessors for client capabilities

2018-04-05 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger updated this revision to Diff 7705.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1944?vs=7505=7705

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

AFFECTED FILES
  mercurial/help/internals/wireprotocol.txt
  mercurial/sshpeer.py
  mercurial/wireproto.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py
  tests/test-debugcommands.t
  tests/test-ssh-bundle1.t
  tests/test-ssh-proto-unbundle.t
  tests/test-ssh-proto.t
  tests/test-ssh.t

CHANGE DETAILS

diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -495,10 +495,13 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403 (sshv1 !)
+  remote: 413 (sshv1 !)
   protocol upgraded to exp-ssh-v2-0001 (sshv2 !)
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1 (sshv1 !)
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   query 1; heads
   devel-peer-request: batched-content
   devel-peer-request:- heads (0 arguments)
diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -63,9 +63,12 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -82,43 +85,43 @@
   i> write(6) -> 6:
   i> hello\n
   o> readline() -> 4:
-  o> 403\n
-  o> readline() -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o> 413\n
+  o> readline() -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
 
 `hg debugserve --sshstdio` works
 
   $ cd server
   $ hg debugserve --sshstdio << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
 
 I/O logging works
 
   $ hg debugserve --sshstdio --logiofd 1 << EOF
   > hello
   > EOF
   o> write(4) -> 4:
-  o> 403\n
-  o> write(403) -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o> 413\n
+  o> write(413) -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> flush() -> None
 
   $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
 
   $ cat $TESTTMP/io
   o> write(4) -> 4:
-  o> 403\n
-  o> 

D1944: wireproto: provide accessors for client capabilities

2018-04-04 Thread indygreg (Gregory Szorc)
indygreg requested changes to this revision.
indygreg added a comment.
This revision now requires changes to proceed.


  I'm OK with the general approach. But this requires a handful of changes 
before it can be accepted.
  
  For protocol version 2, I plan to send client capabilities as part of the 
command request. Now that we are using CBOR for command requests, it will be 
trivial to add client capabilities to the request. We will redundantly send 
capabilities as part of multiple requests. But since we can have an active 
compression context in use across command requests, the wire overhead will be 
negligible. So I'm not worried about the overhead. I care more about making 
server-side command handlers stateless, as that will make it easier to 
implement alternate servers.

INLINE COMMENTS

> wireprotocol.txt:391-393
> +If the server announces support for the ``protocaps`` capability, the client
> +should issue a ``protocaps`` command after the initial handshake to annonunce
> +its own capabilities. The client capabilities are persistent.

This should be in the `SSH Version 1 Transport` section below, because I don't 
intent to carry this stateful feature forward to protocol version 2.

Also, the new capability should be documented in the capabilities section in 
this document.

> wireproto.py:845-847
> +if proto.name in (wireprototypes.SSHV1, wireprototypes.SSHV2):
> +# Advertise support for the ssh-only protocaps command
> +caps.append('protocaps')

The protocol handler class in `wireprotoserver.py` now has an 
`addcapabilities()` that should be used for adding transport-specific 
capabilities. Please use it.

> wireproto.py:1015
>  
> +@wireprotocommand('protocaps', 'caps', permission='pull')
> +def protocaps(repo, proto, caps):

Please define this as `transportpolicy=POLICY_V1_ONLY`.

Also, please add documentation for the new command to `wireprotocol.txt`.

> wireproto.py:1017-1018
> +def protocaps(repo, proto, caps):
> +if proto.name in (wireprototypes.SSHV1, wireprototypes.SSHV2):
> +repo._protocaps = set(caps.split(' '))
> +return bytesresponse('OK')

The transport filtering isn't necessary if this is implemented differently. 
Yes, we could expose the command to HTTP. It shouldn't matter.

Also, please set this on `proto` instead because it is the most appropriate 
place to define this. The protocol handler's lifetime is per connection for SSH 
and per-request for HTTP. The repository instance can outlive the HTTP request 
and the HTTP/SSH connection and it therefore isn't an appropriate place.

> wireprotoserver.py:586
>  self._args = args
> +self._protocaps = None
>  

Please remove this, as we won't carry this implementation forward to version 2.

> wireprotoserver.py:603-606
> +if self._protocaps is None:
> +value = decodevaluefromheaders(self._req, r'X-HgProto')
> +self._protocaps = set(value.split(' '))
> +return self._protocaps

And have this return an empty set for now.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

To: joerg.sonnenberger, #hg-reviewers, indygreg
Cc: indygreg, mharbison72, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1944: wireproto: provide accessors for client capabilities

2018-04-01 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger updated this revision to Diff 7505.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1944?vs=7268=7505

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

AFFECTED FILES
  mercurial/help/internals/wireprotocol.txt
  mercurial/sshpeer.py
  mercurial/wireproto.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py
  tests/test-debugcommands.t
  tests/test-ssh-bundle1.t
  tests/test-ssh-proto-unbundle.t
  tests/test-ssh-proto.t
  tests/test-ssh.t

CHANGE DETAILS

diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -496,10 +496,13 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403 (sshv1 !)
+  remote: 413 (sshv1 !)
   protocol upgraded to exp-ssh-v2-0001 (sshv2 !)
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
   remote: 1 (sshv1 !)
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   query 1; heads
   devel-peer-request: batched-content
   devel-peer-request:- heads (0 arguments)
diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -63,9 +63,12 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -82,43 +85,43 @@
   i> write(6) -> 6:
   i> hello\n
   o> readline() -> 4:
-  o> 403\n
-  o> readline() -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o> 413\n
+  o> readline() -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
 
 `hg debugserve --sshstdio` works
 
   $ cd server
   $ hg debugserve --sshstdio << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
 
 I/O logging works
 
   $ hg debugserve --sshstdio --logiofd 1 << EOF
   > hello
   > EOF
   o> write(4) -> 4:
-  o> 403\n
-  o> write(403) -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o> 413\n
+  o> write(413) -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
   o> flush() -> None
 
   $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
 
   $ cat $TESTTMP/io
   o> write(4) -> 4:
-  o> 403\n
-  o> 

D1944: wireproto: provide accessors for client capabilities

2018-03-24 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger updated this revision to Diff 7268.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1944?vs=5011=7268

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

AFFECTED FILES
  mercurial/help/internals/wireprotocol.txt
  mercurial/sshpeer.py
  mercurial/wireproto.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py
  tests/test-debugcommands.t
  tests/test-ssh-bundle1.t
  tests/test-ssh-proto-unbundle.t
  tests/test-ssh-proto.t
  tests/test-ssh.t

CHANGE DETAILS

diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -496,10 +496,13 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403 (sshv1 !)
+  remote: 413 (sshv1 !)
   protocol upgraded to exp-ssh-v2-0001 (sshv2 !)
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
   remote: 1 (sshv1 !)
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   query 1; heads
   devel-peer-request: batched-content
   devel-peer-request:- heads (0 arguments)
diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -63,9 +63,12 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -82,43 +85,43 @@
   i> write(6) -> 6:
   i> hello\n
   o> readline() -> 4:
-  o> 403\n
-  o> readline() -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o> 413\n
+  o> readline() -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
 
 `hg debugserve --sshstdio` works
 
   $ cd server
   $ hg debugserve --sshstdio << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
 
 I/O logging works
 
   $ hg debugserve --sshstdio --logiofd 1 << EOF
   > hello
   > EOF
   o> write(4) -> 4:
-  o> 403\n
-  o> write(403) -> 403:
-  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch\n
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o> 413\n
+  o> write(413) -> 413:
+  o> capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
   o> flush() -> None
 
   $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash 
protocaps changegroupsubset streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
 
   $ cat $TESTTMP/io
   o> write(4) -> 4:
-  o> 403\n
-  o> 

D1944: wireproto: provide accessors for client capabilities

2018-01-30 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  I've already started work on a ground-up rewrite of the wire protocol. I hope 
to start sending patches on Thursday when the 4.6 release window opens.
  
  I hate to spew "stop energy," but I'm hesitant to accept any new additions to 
the existing wire protocol given a new protocol will soon emerge. The feature 
in this patch is useful. And I will try to work it into my patches. At the very 
least, I'll keep it in the back of my mind as I'm designing things. The new 
wire protocol won't be set in stone from day 0 and we should be able to change 
it throughout the 4.6 cycle. So there will be plenty of time for bikeshedding 
and enhancements in the weeks ahead.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

To: joerg.sonnenberger, #hg-reviewers
Cc: indygreg, mharbison72, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1944: wireproto: provide accessors for client capabilities

2018-01-28 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger added inline comments.

INLINE COMMENTS

> mharbison72 wrote in sshserver.py:74
> See 
> https://phab.mercurial-scm.org/rHGbf2db35a6fe7a02b69eaa0e35708cf0044d73510 
> for an example of # no-check-commit.

Thanks, that answers half of the question. This is an internal interface 
contract, it could be adjusted as well or replaced with an explicit dictionary. 
I have no preference for what is cleaner.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

To: joerg.sonnenberger, #hg-reviewers
Cc: mharbison72, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1944: wireproto: provide accessors for client capabilities

2018-01-27 Thread mharbison72 (Matt Harbison)
mharbison72 added inline comments.

INLINE COMMENTS

> sshserver.py:74
> +
> +def do_protocaps(self):
> +"""ssh-specific command for sending the client capabilities

See https://phab.mercurial-scm.org/rHGbf2db35a6fe7a02b69eaa0e35708cf0044d73510 
for an example of # no-check-commit.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

To: joerg.sonnenberger, #hg-reviewers
Cc: mharbison72, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1944: wireproto: provide accessors for client capabilities

2018-01-27 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger added inline comments.

INLINE COMMENTS

> sshserver.py:74
> +
> +def do_protocaps(self):
> +"""ssh-specific command for sending the client capabilities

So this function triggers the underscore function name check, even if the 
support for this kind of naming is pre-existing. Since the old instances are no 
longer relevant, renaming the callback would be an option too.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1944: wireproto: provide accessors for client capabilities

2018-01-27 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  For HTTP, this refactors the existing logic, including the parsing of
  the compression engine capability.
  
  For SSH, this adds a ssh-only capability "protocaps" and a command for
  informing the server on what the client supports. Since SSH is stateful,
  keep track of the capabilities in the server instance.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1944

AFFECTED FILES
  mercurial/hgweb/protocol.py
  mercurial/sshpeer.py
  mercurial/sshserver.py
  mercurial/wireproto.py
  tests/test-ssh-bundle1.t
  tests/test-ssh.t

CHANGE DETAILS

diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -486,9 +486,12 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 384
-  remote: capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
+  remote: 394
+  remote: capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: 25 bytes
+  sending protocaps command
   query 1; heads
   devel-peer-request: batch
   devel-peer-request:   cmds: 141 bytes
diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t
--- a/tests/test-ssh-bundle1.t
+++ b/tests/test-ssh-bundle1.t
@@ -467,9 +467,10 @@
   running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve 
--stdio('|") (re)
   sending hello command
   sending between command
-  remote: 384
-  remote: capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
+  remote: 394
+  remote: capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps
   remote: 1
+  sending protocaps command
   preparing listkeys for "bookmarks"
   sending listkeys command
   received listkey for "bookmarks": 45 bytes
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -64,6 +64,17 @@
 """
 raise NotImplementedError()
 
+def getprotocaps(self):
+"""return the wireprotocol capabilities of the current request"""
+raise NotImplementedError()
+
+def getcompressionsupport(self):
+"""return a list of compression methods supported by the client"""
+for cap in self.getprotocaps():
+if cap.startswith('comp='):
+return cap[5:].split(',')
+return ['zlib', 'none']
+
 def redirect(self):
 """may setup interception for stdout and stderr
 
@@ -799,6 +810,9 @@
 comptypes = ','.join(urlreq.quote(e.wireprotosupport().name)
  for e in compengines)
 caps.append('compression=%s' % comptypes)
+elif proto.name == 'ssh':
+# Advertise support for the ssh-only protocaps command
+caps.append('protocaps')
 
 return caps
 
diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -27,6 +27,7 @@
 self.fin = ui.fin
 self.fout = ui.fout
 self.name = 'ssh'
+self._protocaps = []
 
 hook.redirect(True)
 ui.fout = repo.ui.fout = ui.ferr
@@ -66,6 +67,20 @@
 fpout.write(self.fin.read(count))
 count = int(self.fin.readline())
 
+def getprotocaps(self):
+"""return the wireprotocol capabilities of the current request"""
+return self._protocaps
+
+def do_protocaps(self):
+"""ssh-specific command for sending the client capabilities
+
+The ssh protocol is stateful and doesn't retransmit the wireprotocol
+capabilities on every request.
+"""
+self._protocaps = self.getargs(self.do_protocaps_arguments)[0]
+self.sendresponse('OK')
+do_protocaps_arguments = 'caps'
+
 def redirect(self):
 pass
 
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -13,6 +13,7 @@
 from . import (
 error,
 pycompat,
+sshserver,
 util,
 wireproto,
 )
@@ -182,6 +183,13 @@
 
 # End of _basewirecommands interface.
 
+def _clientcapabilities(self):
+protoparams = []
+comps = [e.wireprotosupport().name for e in
+ util.compengines.supportedwireengines(util.CLIENTROLE)]
+