comparison mercurial/localrepo.py @ 37633:33a6eee08db2

wireproto: remove iterbatch() from peer interface (API) Good riddance. Some tests have been ported to the new API. This probably should have been done in earlier commits. But duplicating the test coverage would have been difficult. It was easier this way. .. api:: The wire protocol peer's ``iterbatch()`` for bulk executing commands has been remove.d Use ``peer.commandexecutor()`` instead. Differential Revision: https://phab.mercurial-scm.org/D3271
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 11 Apr 2018 16:18:26 -0700
parents e1b32dc4646c
children cc8c06835097
comparison
equal deleted inserted replaced
37632:6c55ce51d6c3 37633:33a6eee08db2
64 tags as tagsmod, 64 tags as tagsmod,
65 transaction, 65 transaction,
66 txnutil, 66 txnutil,
67 util, 67 util,
68 vfs as vfsmod, 68 vfs as vfsmod,
69 wireprotov1peer,
70 ) 69 )
71 from .utils import ( 70 from .utils import (
72 procutil, 71 procutil,
73 stringutil, 72 stringutil,
74 ) 73 )
151 return wrapper 150 return wrapper
152 151
153 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle', 152 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
154 'unbundle'} 153 'unbundle'}
155 legacycaps = moderncaps.union({'changegroupsubset'}) 154 legacycaps = moderncaps.union({'changegroupsubset'})
156
157 class localiterbatcher(wireprotov1peer.iterbatcher):
158 def __init__(self, local):
159 super(localiterbatcher, self).__init__()
160 self.local = local
161
162 def submit(self):
163 # submit for a local iter batcher is a noop
164 pass
165
166 def results(self):
167 for name, args, opts, resref in self.calls:
168 resref.set(getattr(self.local, name)(*args, **opts))
169 yield resref.value
170 155
171 @zi.implementer(repository.ipeercommandexecutor) 156 @zi.implementer(repository.ipeercommandexecutor)
172 class localcommandexecutor(object): 157 class localcommandexecutor(object):
173 def __init__(self, peer): 158 def __init__(self, peer):
174 self._peer = peer 159 self._peer = peer
330 315
331 # Begin of peer interface. 316 # Begin of peer interface.
332 317
333 def commandexecutor(self): 318 def commandexecutor(self):
334 return localcommandexecutor(self) 319 return localcommandexecutor(self)
335
336 def iterbatch(self):
337 return localiterbatcher(self)
338 320
339 # End of peer interface. 321 # End of peer interface.
340 322
341 class locallegacypeer(repository.legacypeer, localpeer): 323 class locallegacypeer(repository.legacypeer, localpeer):
342 '''peer extension which implements legacy methods too; used for tests with 324 '''peer extension which implements legacy methods too; used for tests with