Mercurial > hg
comparison hgext/remotefilelog/fileserverclient.py @ 40511:466dd4d70bff
remotefilelog: rename wireproto methods and remaining capabilities
This is a mess, in part because there should be more constants
throughout. I know we typically do exp- instead of the x_ business in
this change, but I also had to use this in some function names, so I
figured until I can break that coupling I'd go with this. If it's too
unpleasant during review, let me know and I can probably clean it up
some more.
# no-check-commit due to new foo_bar naming - too hard to avoid right now :(
Differential Revision: https://phab.mercurial-scm.org/D5129
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 04 Oct 2018 10:03:10 -0400 |
parents | fc2766860796 |
children | 13d4ad8d7801 |
comparison
equal
deleted
inserted
replaced
40510:fc2766860796 | 40511:466dd4d70bff |
---|---|
52 | 52 |
53 def peersetup(ui, peer): | 53 def peersetup(ui, peer): |
54 | 54 |
55 class remotefilepeer(peer.__class__): | 55 class remotefilepeer(peer.__class__): |
56 @wireprotov1peer.batchable | 56 @wireprotov1peer.batchable |
57 def getfile(self, file, node): | 57 def x_rfl_getfile(self, file, node): |
58 if not self.capable('getfile'): | 58 if not self.capable('x_rfl_getfile'): |
59 raise error.Abort( | 59 raise error.Abort( |
60 'configured remotefile server does not support getfile') | 60 'configured remotefile server does not support getfile') |
61 f = wireprotov1peer.future() | 61 f = wireprotov1peer.future() |
62 yield {'file': file, 'node': node}, f | 62 yield {'file': file, 'node': node}, f |
63 code, data = f.value.split('\0', 1) | 63 code, data = f.value.split('\0', 1) |
64 if int(code): | 64 if int(code): |
65 raise error.LookupError(file, node, data) | 65 raise error.LookupError(file, node, data) |
66 yield data | 66 yield data |
67 | 67 |
68 @wireprotov1peer.batchable | 68 @wireprotov1peer.batchable |
69 def getflogheads(self, path): | 69 def x_rfl_getflogheads(self, path): |
70 if not self.capable('getflogheads'): | 70 if not self.capable('x_rfl_getflogheads'): |
71 raise error.Abort('configured remotefile server does not ' | 71 raise error.Abort('configured remotefile server does not ' |
72 'support getflogheads') | 72 'support getflogheads') |
73 f = wireprotov1peer.future() | 73 f = wireprotov1peer.future() |
74 yield {'path': path}, f | 74 yield {'path': path}, f |
75 heads = f.value.split('\n') if f.value else [] | 75 heads = f.value.split('\n') if f.value else [] |
202 # should probably introduce a streambatch() method upstream and | 202 # should probably introduce a streambatch() method upstream and |
203 # use that for this. | 203 # use that for this. |
204 with remote.commandexecutor() as e: | 204 with remote.commandexecutor() as e: |
205 futures = [] | 205 futures = [] |
206 for m in missed: | 206 for m in missed: |
207 futures.append(e.callcommand('getfile', { | 207 futures.append(e.callcommand('x_rfl_getfile', { |
208 'file': idmap[m], | 208 'file': idmap[m], |
209 'node': m[-40:] | 209 'node': m[-40:] |
210 })) | 210 })) |
211 | 211 |
212 for i, m in enumerate(missed): | 212 for i, m in enumerate(missed): |
217 receivemissing(io.BytesIO('%d\n%s' % (len(r), r)), file_, node) | 217 receivemissing(io.BytesIO('%d\n%s' % (len(r), r)), file_, node) |
218 progresstick() | 218 progresstick() |
219 | 219 |
220 def _getfiles_optimistic( | 220 def _getfiles_optimistic( |
221 remote, receivemissing, progresstick, missed, idmap, step): | 221 remote, receivemissing, progresstick, missed, idmap, step): |
222 remote._callstream("getfiles") | 222 remote._callstream("x_rfl_getfiles") |
223 i = 0 | 223 i = 0 |
224 pipeo = remote._pipeo | 224 pipeo = remote._pipeo |
225 pipei = remote._pipei | 225 pipei = remote._pipei |
226 while i < len(missed): | 226 while i < len(missed): |
227 # issue a batch of requests | 227 # issue a batch of requests |
392 _getfiles = _getfiles_threaded | 392 _getfiles = _getfiles_threaded |
393 else: | 393 else: |
394 _getfiles = _getfiles_optimistic | 394 _getfiles = _getfiles_optimistic |
395 _getfiles(remote, self.receivemissing, progresstick, | 395 _getfiles(remote, self.receivemissing, progresstick, |
396 missed, idmap, step) | 396 missed, idmap, step) |
397 elif remote.capable("getfile"): | 397 elif remote.capable("x_rfl_getfile"): |
398 if remote.capable('batch'): | 398 if remote.capable('batch'): |
399 batchdefault = 100 | 399 batchdefault = 100 |
400 else: | 400 else: |
401 batchdefault = 10 | 401 batchdefault = 10 |
402 batchsize = self.ui.configint( | 402 batchsize = self.ui.configint( |