--- a/mercurial/wireprotov2server.py Wed Oct 03 13:07:28 2018 -0700
+++ b/mercurial/wireprotov2server.py Mon Oct 08 17:45:51 2018 -0700
@@ -518,6 +518,10 @@
'permissions': [entry.permission],
}
+ if entry.extracapabilitiesfn:
+ extracaps = entry.extracapabilitiesfn(repo, proto)
+ caps['commands'][command].update(extracaps)
+
caps['rawrepoformats'] = sorted(repo.requirements &
repo.supportedformats)
@@ -581,7 +585,8 @@
"""
return []
-def wireprotocommand(name, args=None, permission='push', cachekeyfn=None):
+def wireprotocommand(name, args=None, permission='push', cachekeyfn=None,
+ extracapabilitiesfn=None):
"""Decorator to declare a wire protocol command.
``name`` is the name of the wire protocol command being provided.
@@ -613,6 +618,12 @@
``cachekeyfn`` defines an optional callable that can derive the
cache key for this request.
+ ``extracapabilitiesfn`` defines an optional callable that defines extra
+ command capabilities/parameters that are advertised next to the command
+ in the capabilities data structure describing the server. The callable
+ receives as arguments the repository and protocol objects. It returns
+ a dict of extra fields to add to the command descriptor.
+
Wire protocol commands are generators of objects to be serialized and
sent to the client.
@@ -675,7 +686,7 @@
COMMANDS[name] = wireprototypes.commandentry(
func, args=args, transports=transports, permission=permission,
- cachekeyfn=cachekeyfn)
+ cachekeyfn=cachekeyfn, extracapabilitiesfn=extracapabilitiesfn)
return func
@@ -1091,6 +1102,14 @@
yield node
+def manifestdatacapabilities(repo, proto):
+ batchsize = repo.ui.configint(
+ b'experimental', b'server.manifestdata.recommended-batch-size')
+
+ return {
+ b'recommendedbatchsize': batchsize,
+ }
+
@wireprotocommand(
'manifestdata',
args={
@@ -1115,7 +1134,8 @@
},
},
permission='pull',
- cachekeyfn=makecommandcachekeyfn('manifestdata', 1, allargs=True))
+ cachekeyfn=makecommandcachekeyfn('manifestdata', 1, allargs=True),
+ extracapabilitiesfn=manifestdatacapabilities)
def manifestdata(repo, proto, haveparents, nodes, fields, tree):
store = repo.manifestlog.getstorage(tree)