Mercurial > hg
diff tests/wireprotosimplecache.py @ 40023:10cf8b116dd8
wireprotov2: advertise redirect targets in capabilities
This is pretty straightforward.
Redirect targets will require an extension to support. So we've added
a function that can be wrapped to define redirect targets.
To test this, we teach our simple cache test extension to read
redirect targets from a file. It's a bit hacky. But it gets the
job done.
Differential Revision: https://phab.mercurial-scm.org/D4775
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 26 Sep 2018 17:46:48 -0700 |
parents | c537144fdbef |
children | b099e6032f38 |
line wrap: on
line diff
--- a/tests/wireprotosimplecache.py Wed Sep 26 18:02:06 2018 -0700 +++ b/tests/wireprotosimplecache.py Wed Sep 26 17:46:48 2018 -0700 @@ -17,6 +17,7 @@ ) from mercurial.utils import ( interfaceutil, + stringutil, ) CACHE = None @@ -26,6 +27,8 @@ configitem('simplecache', 'cacheobjects', default=False) +configitem('simplecache', 'redirectsfile', + default=None) @interfaceutil.implementer(repository.iwireprotocolcommandcacher) class memorycacher(object): @@ -91,6 +94,19 @@ def makeresponsecacher(orig, repo, proto, command, args, objencoderfn): return memorycacher(repo.ui, command, objencoderfn) +def loadredirecttargets(ui): + path = ui.config('simplecache', 'redirectsfile') + if not path: + return [] + + with open(path, 'rb') as fh: + s = fh.read() + + return stringutil.evalpythonliteral(s) + +def getadvertisedredirecttargets(orig, repo, proto): + return loadredirecttargets(repo.ui) + def extsetup(ui): global CACHE @@ -98,3 +114,5 @@ extensions.wrapfunction(wireprotov2server, 'makeresponsecacher', makeresponsecacher) + extensions.wrapfunction(wireprotov2server, 'getadvertisedredirecttargets', + getadvertisedredirecttargets)