Mercurial > hg
changeset 37610:98861a2298b5
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
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 10 Apr 2018 18:47:09 -0700 |
parents | 01bfe5ad0c53 |
children | ae8730877371 |
files | mercurial/repository.py |
diffstat | 1 files changed, 21 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/repository.py Wed Apr 11 11:03:45 2018 -0700 +++ b/mercurial/repository.py Tue Apr 10 18:47:09 2018 -0700 @@ -61,6 +61,26 @@ 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 @@ 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 @@ 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."""