# HG changeset patch # User Gregory Szorc # Date 2018-04-11 01:47:09 # Node ID 98861a2298b50d063e17f778368c503c6f0292d2 # Parent 01bfe5ad0c5379da027b3c25a2f82f26582d2b22 repository: split capabilities methods into separate interface So we can implement them without having to implement support for every command. Differential Revision: https://phab.mercurial-scm.org/D3255 diff --git a/mercurial/repository.py b/mercurial/repository.py --- a/mercurial/repository.py +++ b/mercurial/repository.py @@ -61,6 +61,26 @@ class ipeerconnection(zi.Interface): associated with the peer should be cleaned up. """ +class ipeercapabilities(zi.Interface): + """Peer sub-interface related to capabilities.""" + + def capable(name): + """Determine support for a named capability. + + Returns ``False`` if capability not supported. + + Returns ``True`` if boolean capability is supported. Returns a string + if capability support is non-boolean. + + Capability strings may or may not map to wire protocol capabilities. + """ + + def requirecap(name, purpose): + """Require a capability to be present. + + Raises a ``CapabilityError`` if the capability isn't present. + """ + class ipeercommands(zi.Interface): """Client-side interface for communicating over the wire protocol. @@ -176,7 +196,7 @@ class ipeerlegacycommands(zi.Interface): def changegroupsubset(bases, heads, kind): pass -class ipeerbase(ipeerconnection, ipeercommands): +class ipeerbase(ipeerconnection, ipeercapabilities, ipeercommands): """Unified interface for peer repositories. All peer instances must conform to this interface. @@ -205,21 +225,6 @@ class ipeerbase(ipeerconnection, ipeerco calls. However, they must all support this API. """ - def capable(name): - """Determine support for a named capability. - - Returns ``False`` if capability not supported. - - Returns ``True`` if boolean capability is supported. Returns a string - if capability support is non-boolean. - """ - - def requirecap(name, purpose): - """Require a capability to be present. - - Raises a ``CapabilityError`` if the capability isn't present. - """ - class ipeerbaselegacycommands(ipeerbase, ipeerlegacycommands): """Unified peer interface that supports legacy commands."""