Mercurial > hg
comparison mercurial/wireprotov1peer.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | a61287a95dc3 |
children | 05dd091dfa6a |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
34 | 34 |
35 urlreq = util.urlreq | 35 urlreq = util.urlreq |
36 | 36 |
37 | 37 |
38 def batchable(f): | 38 def batchable(f): |
39 '''annotation for batchable methods | 39 """annotation for batchable methods |
40 | 40 |
41 Such methods must implement a coroutine as follows: | 41 Such methods must implement a coroutine as follows: |
42 | 42 |
43 @batchable | 43 @batchable |
44 def sample(self, one, two=None): | 44 def sample(self, one, two=None): |
54 | 54 |
55 The decorator returns a function which wraps this coroutine as a plain | 55 The decorator returns a function which wraps this coroutine as a plain |
56 method, but adds the original method as an attribute called "batchable", | 56 method, but adds the original method as an attribute called "batchable", |
57 which is used by remotebatch to split the call into separate encoding and | 57 which is used by remotebatch to split the call into separate encoding and |
58 decoding phases. | 58 decoding phases. |
59 ''' | 59 """ |
60 | 60 |
61 def plain(*args, **opts): | 61 def plain(*args, **opts): |
62 batchable = f(*args, **opts) | 62 batchable = f(*args, **opts) |
63 encargsorres, encresref = next(batchable) | 63 encargsorres, encresref = next(batchable) |
64 if not encresref: | 64 if not encresref: |
472 return bundle2.getunbundler(self.ui, f) | 472 return bundle2.getunbundler(self.ui, f) |
473 else: | 473 else: |
474 return changegroupmod.cg1unpacker(f, b'UN') | 474 return changegroupmod.cg1unpacker(f, b'UN') |
475 | 475 |
476 def unbundle(self, bundle, heads, url): | 476 def unbundle(self, bundle, heads, url): |
477 '''Send cg (a readable file-like object representing the | 477 """Send cg (a readable file-like object representing the |
478 changegroup to push, typically a chunkbuffer object) to the | 478 changegroup to push, typically a chunkbuffer object) to the |
479 remote server as a bundle. | 479 remote server as a bundle. |
480 | 480 |
481 When pushing a bundle10 stream, return an integer indicating the | 481 When pushing a bundle10 stream, return an integer indicating the |
482 result of the push (see changegroup.apply()). | 482 result of the push (see changegroup.apply()). |
483 | 483 |
484 When pushing a bundle20 stream, return a bundle20 stream. | 484 When pushing a bundle20 stream, return a bundle20 stream. |
485 | 485 |
486 `url` is the url the client thinks it's pushing to, which is | 486 `url` is the url the client thinks it's pushing to, which is |
487 visible to hooks. | 487 visible to hooks. |
488 ''' | 488 """ |
489 | 489 |
490 if heads != [b'force'] and self.capable(b'unbundlehash'): | 490 if heads != [b'force'] and self.capable(b'unbundlehash'): |
491 heads = wireprototypes.encodelist( | 491 heads = wireprototypes.encodelist( |
492 [b'hashed', hashutil.sha1(b''.join(sorted(heads))).digest()] | 492 [b'hashed', hashutil.sha1(b''.join(sorted(heads))).digest()] |
493 ) | 493 ) |
653 The command will send a stream to the server and get a stream in reply. | 653 The command will send a stream to the server and get a stream in reply. |
654 """ | 654 """ |
655 raise NotImplementedError() | 655 raise NotImplementedError() |
656 | 656 |
657 def _abort(self, exception): | 657 def _abort(self, exception): |
658 """clearly abort the wire protocol connection and raise the exception | 658 """clearly abort the wire protocol connection and raise the exception""" |
659 """ | |
660 raise NotImplementedError() | 659 raise NotImplementedError() |