comparison mercurial/localrepo.py @ 37615:f3dc8239e3a9

peer: scatter module to the wind (API) peer.py hardly contained any code. The code it did contain was generic to the version 1 peer interface or specific to the local repository peer. So code has been moved to wireprotov1peer and localrepo, as appropriate. Differential Revision: https://phab.mercurial-scm.org/D3260
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 11 Apr 2018 12:51:09 -0700
parents ecd3f6909184
children e1b32dc4646c
comparison
equal deleted inserted replaced
37614:a81d02ea65db 37615:f3dc8239e3a9
47 mergeutil, 47 mergeutil,
48 namespaces, 48 namespaces,
49 narrowspec, 49 narrowspec,
50 obsolete, 50 obsolete,
51 pathutil, 51 pathutil,
52 peer,
53 phases, 52 phases,
54 pushkey, 53 pushkey,
55 pycompat, 54 pycompat,
56 repository, 55 repository,
57 repoview, 56 repoview,
64 tags as tagsmod, 63 tags as tagsmod,
65 transaction, 64 transaction,
66 txnutil, 65 txnutil,
67 util, 66 util,
68 vfs as vfsmod, 67 vfs as vfsmod,
68 wireprotov1peer,
69 ) 69 )
70 from .utils import ( 70 from .utils import (
71 procutil, 71 procutil,
72 stringutil, 72 stringutil,
73 ) 73 )
150 return wrapper 150 return wrapper
151 151
152 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle', 152 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
153 'unbundle'} 153 'unbundle'}
154 legacycaps = moderncaps.union({'changegroupsubset'}) 154 legacycaps = moderncaps.union({'changegroupsubset'})
155
156 class localiterbatcher(wireprotov1peer.iterbatcher):
157 def __init__(self, local):
158 super(localiterbatcher, self).__init__()
159 self.local = local
160
161 def submit(self):
162 # submit for a local iter batcher is a noop
163 pass
164
165 def results(self):
166 for name, args, opts, resref in self.calls:
167 resref.set(getattr(self.local, name)(*args, **opts))
168 yield resref.value
155 169
156 class localpeer(repository.peer): 170 class localpeer(repository.peer):
157 '''peer for a local repo; reflects only the most recent API''' 171 '''peer for a local repo; reflects only the most recent API'''
158 172
159 def __init__(self, repo, caps=None): 173 def __init__(self, repo, caps=None):
271 # End of _basewirecommands interface. 285 # End of _basewirecommands interface.
272 286
273 # Begin of peer interface. 287 # Begin of peer interface.
274 288
275 def iterbatch(self): 289 def iterbatch(self):
276 return peer.localiterbatcher(self) 290 return localiterbatcher(self)
277 291
278 # End of peer interface. 292 # End of peer interface.
279 293
280 class locallegacypeer(repository.legacypeer, localpeer): 294 class locallegacypeer(repository.legacypeer, localpeer):
281 '''peer extension which implements legacy methods too; used for tests with 295 '''peer extension which implements legacy methods too; used for tests with