equal
deleted
inserted
replaced
310 |
310 |
311 res.status = b'200 OK' |
311 res.status = b'200 OK' |
312 res.headers[b'Content-Type'] = FRAMINGTYPE |
312 res.headers[b'Content-Type'] = FRAMINGTYPE |
313 |
313 |
314 try: |
314 try: |
315 objs = dispatch(repo, proto, command['command']) |
315 objs = dispatch(repo, proto, command['command'], command['redirect']) |
316 |
316 |
317 action, meta = reactor.oncommandresponsereadyobjects( |
317 action, meta = reactor.oncommandresponsereadyobjects( |
318 outstream, command['requestid'], objs) |
318 outstream, command['requestid'], objs) |
319 |
319 |
320 except error.WireprotoCommandError as e: |
320 except error.WireprotoCommandError as e: |
337 action) |
337 action) |
338 |
338 |
339 def getdispatchrepo(repo, proto, command): |
339 def getdispatchrepo(repo, proto, command): |
340 return repo.filtered('served') |
340 return repo.filtered('served') |
341 |
341 |
342 def dispatch(repo, proto, command): |
342 def dispatch(repo, proto, command, redirect): |
343 """Run a wire protocol command. |
343 """Run a wire protocol command. |
344 |
344 |
345 Returns an iterable of objects that will be sent to the client. |
345 Returns an iterable of objects that will be sent to the client. |
346 """ |
346 """ |
347 repo = getdispatchrepo(repo, proto, command) |
347 repo = getdispatchrepo(repo, proto, command) |
362 if not entry.cachekeyfn: |
362 if not entry.cachekeyfn: |
363 for o in callcommand(): |
363 for o in callcommand(): |
364 yield o |
364 yield o |
365 return |
365 return |
366 |
366 |
|
367 if redirect: |
|
368 redirecttargets = redirect[b'targets'] |
|
369 redirecthashes = redirect[b'hashes'] |
|
370 else: |
|
371 redirecttargets = [] |
|
372 redirecthashes = [] |
|
373 |
367 cacher = makeresponsecacher(repo, proto, command, args, |
374 cacher = makeresponsecacher(repo, proto, command, args, |
368 cborutil.streamencode) |
375 cborutil.streamencode, |
|
376 redirecttargets=redirecttargets, |
|
377 redirecthashes=redirecthashes) |
369 |
378 |
370 # But we have no cacher. Do default handling. |
379 # But we have no cacher. Do default handling. |
371 if not cacher: |
380 if not cacher: |
372 for o in callcommand(): |
381 for o in callcommand(): |
373 yield o |
382 yield o |
749 |
758 |
750 return pycompat.sysbytes(hasher.hexdigest()) |
759 return pycompat.sysbytes(hasher.hexdigest()) |
751 |
760 |
752 return cachekeyfn |
761 return cachekeyfn |
753 |
762 |
754 def makeresponsecacher(repo, proto, command, args, objencoderfn): |
763 def makeresponsecacher(repo, proto, command, args, objencoderfn, |
|
764 redirecttargets, redirecthashes): |
755 """Construct a cacher for a cacheable command. |
765 """Construct a cacher for a cacheable command. |
756 |
766 |
757 Returns an ``iwireprotocolcommandcacher`` instance. |
767 Returns an ``iwireprotocolcommandcacher`` instance. |
758 |
768 |
759 Extensions can monkeypatch this function to provide custom caching |
769 Extensions can monkeypatch this function to provide custom caching |