Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/peer.py @ 33827:dedab036215d
wireproto: use new peer interface
The wirepeer class provides concrete implementations of peer interface
methods for calling wire protocol commands. It makes sense for this
class to inherit from the peer abstract base class. So we change
that.
Since httppeer and sshpeer have already been converted to the new
interface, peerrepository is no longer adding any value. So it has
been removed. httppeer and sshpeer have been updated to reflect the
loss of peerrepository and the inheritance of the abstract base
class in wirepeer.
The code changes in wirepeer are reordering of methods to group
by interface.
Some Python code in tests was updated to reflect changed APIs.
.. api::
peer.peerrepository has been removed. Use repository.peer abstract
base class to represent a peer repository.
Differential Revision: https://phab.mercurial-scm.org/D338
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 10 Aug 2017 20:58:28 -0700 |
parents | b47fe9733d76 |
children | 56bb07a0b75c |
comparison
equal
deleted
inserted
replaced
33826:f913e90f15a0 | 33827:dedab036215d |
---|---|
6 # This software may be used and distributed according to the terms of the | 6 # This software may be used and distributed according to the terms of the |
7 # GNU General Public License version 2 or any later version. | 7 # GNU General Public License version 2 or any later version. |
8 | 8 |
9 from __future__ import absolute_import | 9 from __future__ import absolute_import |
10 | 10 |
11 from .i18n import _ | |
12 from . import ( | 11 from . import ( |
13 error, | 12 error, |
14 util, | 13 util, |
15 ) | 14 ) |
16 | 15 |
93 self = args[0] | 92 self = args[0] |
94 encresref.set(self._submitone(f.func_name, encargsorres)) | 93 encresref.set(self._submitone(f.func_name, encargsorres)) |
95 return next(batchable) | 94 return next(batchable) |
96 setattr(plain, 'batchable', f) | 95 setattr(plain, 'batchable', f) |
97 return plain | 96 return plain |
98 | |
99 class peerrepository(object): | |
100 def iterbatch(self): | |
101 """Batch requests but allow iterating over the results. | |
102 | |
103 This is to allow interleaving responses with things like | |
104 progress updates for clients. | |
105 """ | |
106 return localiterbatcher(self) | |
107 | |
108 def capable(self, name): | |
109 '''tell whether repo supports named capability. | |
110 return False if not supported. | |
111 if boolean capability, return True. | |
112 if string capability, return string.''' | |
113 caps = self._capabilities() | |
114 if name in caps: | |
115 return True | |
116 name_eq = name + '=' | |
117 for cap in caps: | |
118 if cap.startswith(name_eq): | |
119 return cap[len(name_eq):] | |
120 return False | |
121 | |
122 def requirecap(self, name, purpose): | |
123 '''raise an exception if the given capability is not present''' | |
124 if not self.capable(name): | |
125 raise error.CapabilityError( | |
126 _('cannot %s; remote repository does not ' | |
127 'support the %r capability') % (purpose, name)) | |
128 | |
129 def local(self): | |
130 '''return peer as a localrepo, or None''' | |
131 return None | |
132 | |
133 def peer(self): | |
134 return self | |
135 | |
136 def canpush(self): | |
137 return True | |
138 | |
139 def close(self): | |
140 pass |