Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/interfaces/repository.py @ 52526:61f70a6ab645
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.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 24 Oct 2024 20:35:02 -0400 |
parents | e123c8a26a70 |
children | 9358d786af24 |
comparison
equal
deleted
inserted
replaced
52525:e123c8a26a70 | 52526:61f70a6ab645 |
---|---|
211 | 211 |
212 This interface is used as a gateway to the Mercurial wire protocol. | 212 This interface is used as a gateway to the Mercurial wire protocol. |
213 methods commonly call wire protocol commands of the same name. | 213 methods commonly call wire protocol commands of the same name. |
214 """ | 214 """ |
215 | 215 |
216 @abc.abstractmethod | |
216 def branchmap(self): | 217 def branchmap(self): |
217 """Obtain heads in named branches. | 218 """Obtain heads in named branches. |
218 | 219 |
219 Returns a dict mapping branch name to an iterable of nodes that are | 220 Returns a dict mapping branch name to an iterable of nodes that are |
220 heads on that branch. | 221 heads on that branch. |
221 """ | 222 """ |
222 | 223 |
224 @abc.abstractmethod | |
223 def capabilities(self): | 225 def capabilities(self): |
224 """Obtain capabilities of the peer. | 226 """Obtain capabilities of the peer. |
225 | 227 |
226 Returns a set of string capabilities. | 228 Returns a set of string capabilities. |
227 """ | 229 """ |
228 | 230 |
231 @abc.abstractmethod | |
229 def get_cached_bundle_inline(self, path): | 232 def get_cached_bundle_inline(self, path): |
230 """Retrieve a clonebundle across the wire. | 233 """Retrieve a clonebundle across the wire. |
231 | 234 |
232 Returns a chunkbuffer | 235 Returns a chunkbuffer |
233 """ | 236 """ |
234 | 237 |
238 @abc.abstractmethod | |
235 def clonebundles(self): | 239 def clonebundles(self): |
236 """Obtains the clone bundles manifest for the repo. | 240 """Obtains the clone bundles manifest for the repo. |
237 | 241 |
238 Returns the manifest as unparsed bytes. | 242 Returns the manifest as unparsed bytes. |
239 """ | 243 """ |
240 | 244 |
245 @abc.abstractmethod | |
241 def debugwireargs(self, one, two, three=None, four=None, five=None): | 246 def debugwireargs(self, one, two, three=None, four=None, five=None): |
242 """Used to facilitate debugging of arguments passed over the wire.""" | 247 """Used to facilitate debugging of arguments passed over the wire.""" |
243 | 248 |
249 @abc.abstractmethod | |
244 def getbundle(self, source, **kwargs): | 250 def getbundle(self, source, **kwargs): |
245 """Obtain remote repository data as a bundle. | 251 """Obtain remote repository data as a bundle. |
246 | 252 |
247 This command is how the bulk of repository data is transferred from | 253 This command is how the bulk of repository data is transferred from |
248 the peer to the local repository | 254 the peer to the local repository |
249 | 255 |
250 Returns a generator of bundle data. | 256 Returns a generator of bundle data. |
251 """ | 257 """ |
252 | 258 |
259 @abc.abstractmethod | |
253 def heads(self): | 260 def heads(self): |
254 """Determine all known head revisions in the peer. | 261 """Determine all known head revisions in the peer. |
255 | 262 |
256 Returns an iterable of binary nodes. | 263 Returns an iterable of binary nodes. |
257 """ | 264 """ |
258 | 265 |
266 @abc.abstractmethod | |
259 def known(self, nodes): | 267 def known(self, nodes): |
260 """Determine whether multiple nodes are known. | 268 """Determine whether multiple nodes are known. |
261 | 269 |
262 Accepts an iterable of nodes whose presence to check for. | 270 Accepts an iterable of nodes whose presence to check for. |
263 | 271 |
264 Returns an iterable of booleans indicating of the corresponding node | 272 Returns an iterable of booleans indicating of the corresponding node |
265 at that index is known to the peer. | 273 at that index is known to the peer. |
266 """ | 274 """ |
267 | 275 |
276 @abc.abstractmethod | |
268 def listkeys(self, namespace): | 277 def listkeys(self, namespace): |
269 """Obtain all keys in a pushkey namespace. | 278 """Obtain all keys in a pushkey namespace. |
270 | 279 |
271 Returns an iterable of key names. | 280 Returns an iterable of key names. |
272 """ | 281 """ |
273 | 282 |
283 @abc.abstractmethod | |
274 def lookup(self, key): | 284 def lookup(self, key): |
275 """Resolve a value to a known revision. | 285 """Resolve a value to a known revision. |
276 | 286 |
277 Returns a binary node of the resolved revision on success. | 287 Returns a binary node of the resolved revision on success. |
278 """ | 288 """ |
279 | 289 |
290 @abc.abstractmethod | |
280 def pushkey(self, namespace, key, old, new): | 291 def pushkey(self, namespace, key, old, new): |
281 """Set a value using the ``pushkey`` protocol. | 292 """Set a value using the ``pushkey`` protocol. |
282 | 293 |
283 Arguments correspond to the pushkey namespace and key to operate on and | 294 Arguments correspond to the pushkey namespace and key to operate on and |
284 the old and new values for that key. | 295 the old and new values for that key. |
285 | 296 |
286 Returns a string with the peer result. The value inside varies by the | 297 Returns a string with the peer result. The value inside varies by the |
287 namespace. | 298 namespace. |
288 """ | 299 """ |
289 | 300 |
301 @abc.abstractmethod | |
290 def stream_out(self): | 302 def stream_out(self): |
291 """Obtain streaming clone data. | 303 """Obtain streaming clone data. |
292 | 304 |
293 Successful result should be a generator of data chunks. | 305 Successful result should be a generator of data chunks. |
294 """ | 306 """ |
295 | 307 |
308 @abc.abstractmethod | |
296 def unbundle(self, bundle, heads, url): | 309 def unbundle(self, bundle, heads, url): |
297 """Transfer repository data to the peer. | 310 """Transfer repository data to the peer. |
298 | 311 |
299 This is how the bulk of data during a push is transferred. | 312 This is how the bulk of data during a push is transferred. |
300 | 313 |
308 Wire protocol commands transition to legacy status when they are no longer | 321 Wire protocol commands transition to legacy status when they are no longer |
309 used by modern clients. To facilitate identifying which commands are | 322 used by modern clients. To facilitate identifying which commands are |
310 legacy, the interfaces are split. | 323 legacy, the interfaces are split. |
311 """ | 324 """ |
312 | 325 |
326 @abc.abstractmethod | |
313 def between(self, pairs): | 327 def between(self, pairs): |
314 """Obtain nodes between pairs of nodes. | 328 """Obtain nodes between pairs of nodes. |
315 | 329 |
316 ``pairs`` is an iterable of node pairs. | 330 ``pairs`` is an iterable of node pairs. |
317 | 331 |
318 Returns an iterable of iterables of nodes corresponding to each | 332 Returns an iterable of iterables of nodes corresponding to each |
319 requested pair. | 333 requested pair. |
320 """ | 334 """ |
321 | 335 |
336 @abc.abstractmethod | |
322 def branches(self, nodes): | 337 def branches(self, nodes): |
323 """Obtain ancestor changesets of specific nodes back to a branch point. | 338 """Obtain ancestor changesets of specific nodes back to a branch point. |
324 | 339 |
325 For each requested node, the peer finds the first ancestor node that is | 340 For each requested node, the peer finds the first ancestor node that is |
326 a DAG root or is a merge. | 341 a DAG root or is a merge. |
327 | 342 |
328 Returns an iterable of iterables with the resolved values for each node. | 343 Returns an iterable of iterables with the resolved values for each node. |
329 """ | 344 """ |
330 | 345 |
346 @abc.abstractmethod | |
331 def changegroup(self, nodes, source): | 347 def changegroup(self, nodes, source): |
332 """Obtain a changegroup with data for descendants of specified nodes.""" | 348 """Obtain a changegroup with data for descendants of specified nodes.""" |
333 | 349 |
350 @abc.abstractmethod | |
334 def changegroupsubset(self, bases, heads, source): | 351 def changegroupsubset(self, bases, heads, source): |
335 pass | 352 pass |
336 | 353 |
337 | 354 |
338 class ipeercommandexecutor(Protocol): | 355 class ipeercommandexecutor(Protocol): |