changeset 42158:69921d02daaf

peer: introduce a limitedarguments attributes When set to True, it signal that the peer cannot receive too larges arguments and that algorithm must adapt. This should only be True for http peer that does not support argument passed as "post". This will be useful to unlock better discovery performance in the next changesets. I am using a dedicated argument because this is not really a usual "capabilities" things. An alternative approach would be to adds a "large-arguments" to all peer, but the http peers. That seemed a bit too hacky to me.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 17 Apr 2019 17:56:30 +0200
parents 7755b89cadaf
children 4f9a89837f07
files mercurial/httppeer.py mercurial/repository.py
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Wed Mar 06 15:06:53 2019 +0100
+++ b/mercurial/httppeer.py	Wed Apr 17 17:56:30 2019 +0200
@@ -382,6 +382,7 @@
         self._path = path
         self._url = url
         self._caps = caps
+        self.limitedarguments = caps is not None and 'httppostargs' not in caps
         self._urlopener = opener
         self._requestbuilder = requestbuilder
 
@@ -750,6 +751,9 @@
 
 @interfaceutil.implementer(repository.ipeerv2)
 class httpv2peer(object):
+
+    limitedarguments = False
+
     def __init__(self, ui, repourl, apipath, opener, requestbuilder,
                  apidescriptor):
         self.ui = ui
--- a/mercurial/repository.py	Wed Mar 06 15:06:53 2019 +0100
+++ b/mercurial/repository.py	Wed Apr 17 17:56:30 2019 +0200
@@ -291,6 +291,10 @@
 class ipeerrequests(interfaceutil.Interface):
     """Interface for executing commands on a peer."""
 
+    limitedarguments = interfaceutil.Attribute(
+        """True if the peer cannot receive large argument value for commands."""
+    )
+
     def commandexecutor():
         """A context manager that resolves to an ipeercommandexecutor.
 
@@ -329,6 +333,8 @@
 class peer(object):
     """Base class for peer repositories."""
 
+    limitedarguments = False
+
     def capable(self, name):
         caps = self.capabilities()
         if name in caps: