Skip to content
Snippets Groups Projects
Commit 88022951 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

gitrepo: fake the batchable peer API harder

Since 4.9, mercurial has strong expectation about `peer.lookup` being a
batchable wire protocol command. So we need to actually "implement" that in our
fake peer. The API is now compatible with that, backed by an hollow
implementation. Since the peer is not doing any network operation, we don't
need any actual code.
parent 0246cda6
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@
from mercurial.peer import peerrepository
class gitrepo(peerrepository):
class basegitrepo(peerrepository):
def __init__(self, ui, path, create, intents=None, **kwargs):
if create: # pragma: no cover
raise error.Abort('Cannot create a git repository.')
......@@ -96,9 +96,51 @@
def unbundle(self):
raise NotImplementedError
def commandexecutor(self):
from mercurial.wireprotov1peer import peerexecutor
return peerexecutor(self)
try:
from mercurial.wireprotov1peer import (
batchable,
future,
peerexecutor,
)
except ImportError:
# compat with <= hg-4.8
gitrepo = basegitrepo
else:
class gitrepo(basegitrepo):
@batchable
def lookup(self, key):
f = future()
yield {}, f
yield super(gitrepo, self).lookup(key)
@batchable
def heads(self):
f = future()
yield {}, f
yield super(gitrepo, self).heads()
@batchable
def listkeys(self, namespace):
f = future()
yield {}, f
yield super(gitrepo, self).listkeys(namespace)
@batchable
def pushkey(self, namespace, key, old, new):
f = future()
yield {}, f
yield super(gitrepo, self).pushkey(key, old, new)
def commandexecutor(self):
return peerexecutor(self)
def _submitbatch(self, req):
for op, argsdict in req:
yield None
def _submitone(self, op, args):
return None
instance = gitrepo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment