# HG changeset patch # User Gregory Szorc # Date 1523300232 25200 # Node ID 693cb37689437b18c8056153bafebfb255026176 # Parent 4a0d58d6faba9e82e889bc4dbdf8eef627fdfb05 wireproto: make @wireprotocommand version 1 only by default For backwards compatibility reasons. We want extension provided commands to opt in to version 2 rather than get inherited automatically. This will facilitate a clean break between the protocols. As part of this, we duplicate some commands used in tests so there are different command handlers per transport. Differential Revision: https://phab.mercurial-scm.org/D3207 diff -r 4a0d58d6faba -r 693cb3768943 mercurial/wireproto.py --- a/mercurial/wireproto.py Mon Apr 09 11:54:31 2018 -0700 +++ b/mercurial/wireproto.py Mon Apr 09 11:57:12 2018 -0700 @@ -707,7 +707,7 @@ # For version 2 transports. commandsv2 = commanddict() -def wireprotocommand(name, args='', transportpolicy=POLICY_ALL, +def wireprotocommand(name, args='', transportpolicy=POLICY_V1_ONLY, permission='push'): """Decorator to declare a wire protocol command. diff -r 4a0d58d6faba -r 693cb3768943 tests/wireprotohelpers.sh --- a/tests/wireprotohelpers.sh Mon Apr 09 11:54:31 2018 -0700 +++ b/tests/wireprotohelpers.sh Mon Apr 09 11:57:12 2018 -0700 @@ -16,12 +16,22 @@ ) @wireproto.wireprotocommand('customreadonly', permission='pull') -def customreadonly(repo, proto): +def customreadonlyv1(repo, proto): + return wireprototypes.bytesresponse(b'customreadonly bytes response') + +@wireproto.wireprotocommand('customreadonly', permission='pull', + transportpolicy=wireproto.POLICY_V2_ONLY) +def customreadonlyv2(repo, proto): return wireprototypes.bytesresponse(b'customreadonly bytes response') @wireproto.wireprotocommand('customreadwrite', permission='push') def customreadwrite(repo, proto): return wireprototypes.bytesresponse(b'customreadwrite bytes response') + +@wireproto.wireprotocommand('customreadwrite', permission='push', + transportpolicy=wireproto.POLICY_V2_ONLY) +def customreadwritev2(repo, proto): + return wireprototypes.bytesresponse(b'customreadwrite bytes response') EOF cat >> $HGRCPATH << EOF