Mercurial > public > mercurial-scm > hg
comparison mercurial/peer.py @ 33767:b47fe9733d76
peer: remove non iterating batcher (API)
The last use of this API was removed in b6e71f8af5b8 in 2016. While
not formally deprecated, as of the last commit the code is no longer
explicitly tested. I think the new API has existed long enough for
people to transition to it.
I also have plans to more formalize the peer API and removing batch()
makes that work easier.
I'm not convinced the current client-side API around batching is
great. But it's the best we have at the moment.
.. api:: remove peer.batch()
Replace with peer.iterbatch().
Differential Revision: https://phab.mercurial-scm.org/D320
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 09 Aug 2017 23:35:20 -0700 |
parents | 4c706037adef |
children | dedab036215d |
comparison
equal
deleted
inserted
replaced
33766:4c706037adef | 33767:b47fe9733d76 |
---|---|
47 raise NotImplementedError() | 47 raise NotImplementedError() |
48 | 48 |
49 def results(self): | 49 def results(self): |
50 raise NotImplementedError() | 50 raise NotImplementedError() |
51 | 51 |
52 class localbatch(batcher): | |
53 '''performs the queued calls directly''' | |
54 def __init__(self, local): | |
55 batcher.__init__(self) | |
56 self.local = local | |
57 def submit(self): | |
58 for name, args, opts, resref in self.calls: | |
59 resref.set(getattr(self.local, name)(*args, **opts)) | |
60 | |
61 class localiterbatcher(iterbatcher): | 52 class localiterbatcher(iterbatcher): |
62 def __init__(self, local): | 53 def __init__(self, local): |
63 super(iterbatcher, self).__init__() | 54 super(iterbatcher, self).__init__() |
64 self.local = local | 55 self.local = local |
65 | 56 |
104 return next(batchable) | 95 return next(batchable) |
105 setattr(plain, 'batchable', f) | 96 setattr(plain, 'batchable', f) |
106 return plain | 97 return plain |
107 | 98 |
108 class peerrepository(object): | 99 class peerrepository(object): |
109 | |
110 def batch(self): | |
111 return localbatch(self) | |
112 | |
113 def iterbatch(self): | 100 def iterbatch(self): |
114 """Batch requests but allow iterating over the results. | 101 """Batch requests but allow iterating over the results. |
115 | 102 |
116 This is to allow interleaving responses with things like | 103 This is to allow interleaving responses with things like |
117 progress updates for clients. | 104 progress updates for clients. |