wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
This is the same transformation as 3a90a6fd710d did for dirstate, but the
CamelCase naming was already cleaned up here. See 4ef6dbc27a99 for the benefits
of explicit subclassing.
PyCharm is flagging the `wirepeer.getbundle` function with:
Type of 'getbundle' is incompatible with 'ipeercommands'
I've no idea why- maybe it's because it can infer a `unbundle20 | cg1unpacker`
return there, or maybe it's the kwargs. Something to keep an eye on, but pytype
doesn't complain.
Since we're direct subclassing here and there are only a few methods on these
interfaces, also make them abstract like was done in ef119f914fc1.
--- a/mercurial/interfaces/repository.py Thu Oct 24 20:26:25 2024 -0400
+++ b/mercurial/interfaces/repository.py Thu Oct 24 20:35:02 2024 -0400
@@ -213,6 +213,7 @@
methods commonly call wire protocol commands of the same name.
"""
+ @abc.abstractmethod
def branchmap(self):
"""Obtain heads in named branches.
@@ -220,27 +221,32 @@
heads on that branch.
"""
+ @abc.abstractmethod
def capabilities(self):
"""Obtain capabilities of the peer.
Returns a set of string capabilities.
"""
+ @abc.abstractmethod
def get_cached_bundle_inline(self, path):
"""Retrieve a clonebundle across the wire.
Returns a chunkbuffer
"""
+ @abc.abstractmethod
def clonebundles(self):
"""Obtains the clone bundles manifest for the repo.
Returns the manifest as unparsed bytes.
"""
+ @abc.abstractmethod
def debugwireargs(self, one, two, three=None, four=None, five=None):
"""Used to facilitate debugging of arguments passed over the wire."""
+ @abc.abstractmethod
def getbundle(self, source, **kwargs):
"""Obtain remote repository data as a bundle.
@@ -250,12 +256,14 @@
Returns a generator of bundle data.
"""
+ @abc.abstractmethod
def heads(self):
"""Determine all known head revisions in the peer.
Returns an iterable of binary nodes.
"""
+ @abc.abstractmethod
def known(self, nodes):
"""Determine whether multiple nodes are known.
@@ -265,18 +273,21 @@
at that index is known to the peer.
"""
+ @abc.abstractmethod
def listkeys(self, namespace):
"""Obtain all keys in a pushkey namespace.
Returns an iterable of key names.
"""
+ @abc.abstractmethod
def lookup(self, key):
"""Resolve a value to a known revision.
Returns a binary node of the resolved revision on success.
"""
+ @abc.abstractmethod
def pushkey(self, namespace, key, old, new):
"""Set a value using the ``pushkey`` protocol.
@@ -287,12 +298,14 @@
namespace.
"""
+ @abc.abstractmethod
def stream_out(self):
"""Obtain streaming clone data.
Successful result should be a generator of data chunks.
"""
+ @abc.abstractmethod
def unbundle(self, bundle, heads, url):
"""Transfer repository data to the peer.
@@ -310,6 +323,7 @@
legacy, the interfaces are split.
"""
+ @abc.abstractmethod
def between(self, pairs):
"""Obtain nodes between pairs of nodes.
@@ -319,6 +333,7 @@
requested pair.
"""
+ @abc.abstractmethod
def branches(self, nodes):
"""Obtain ancestor changesets of specific nodes back to a branch point.
@@ -328,9 +343,11 @@
Returns an iterable of iterables with the resolved values for each node.
"""
+ @abc.abstractmethod
def changegroup(self, nodes, source):
"""Obtain a changegroup with data for descendants of specified nodes."""
+ @abc.abstractmethod
def changegroupsubset(self, bases, heads, source):
pass
--- a/mercurial/wireprotov1peer.py Thu Oct 24 20:26:25 2024 -0400
+++ b/mercurial/wireprotov1peer.py Thu Oct 24 20:35:02 2024 -0400
@@ -25,7 +25,6 @@
)
from .interfaces import (
repository,
- util as interfaceutil,
)
from .utils import hashutil
@@ -321,10 +320,9 @@
f.set_result(result)
-@interfaceutil.implementer(
- repository.ipeercommands, repository.ipeerlegacycommands
-)
-class wirepeer(repository.peer):
+class wirepeer(
+ repository.peer, repository.ipeercommands, repository.ipeerlegacycommands
+):
"""Client-side interface for communicating with a peer repository.
Methods commonly call wire protocol commands of the same name.