mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
98d9269874
Summary: Create a fork of the Mercurial code that we can use to build server rpms. The hg servers will continue to exist for a few more months while we move the darkstorm and ediscovery use cases off them. In the mean time, we want to start making breaking changes to the client, so let's create a stable copy of the hg code to produce rpms for the hg servers. The fork is based off c7770c78d, the latest hg release. This copies the files as is, then adds some minor tweaks to get it to build: - Disables some lint checks that appear to be bypassed by path - sed replace eden/scm with eden/hg-server - Removed a dependency on scm/telemetry from the edenfs-client tests since scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts with the hg-server conflict parser. allow-large-files Reviewed By: quark-zju Differential Revision: D27632557 fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
96 lines
1.9 KiB
Python
96 lines
1.9 KiB
Python
from __future__ import absolute_import, print_function
|
|
|
|
from edenscm.mercurial import pycompat, ui, util, wireproto
|
|
from hghave import require
|
|
|
|
|
|
stringio = util.stringio
|
|
|
|
|
|
class proto(object):
|
|
def __init__(self, args):
|
|
self.args = args
|
|
|
|
def getargs(self, spec):
|
|
args = self.args
|
|
args.setdefault("*", {})
|
|
names = spec.split()
|
|
return [args[n] for n in names]
|
|
|
|
|
|
class clientpeer(wireproto.wirepeer):
|
|
def __init__(self, serverrepo):
|
|
self.serverrepo = serverrepo
|
|
|
|
@property
|
|
def ui(self):
|
|
return self.serverrepo.ui
|
|
|
|
def url(self):
|
|
return "test"
|
|
|
|
def local(self):
|
|
return None
|
|
|
|
def peer(self):
|
|
return self
|
|
|
|
def canpush(self):
|
|
return True
|
|
|
|
def close(self):
|
|
pass
|
|
|
|
def capabilities(self):
|
|
return ["batch"]
|
|
|
|
def _call(self, cmd, **args):
|
|
res = wireproto.dispatch(self.serverrepo, proto(args), cmd)
|
|
if isinstance(res, str):
|
|
res = pycompat.encodeutf8(res)
|
|
return res
|
|
|
|
def _callstream(self, cmd, **args):
|
|
return stringio(self._call(cmd, **args))
|
|
|
|
@wireproto.batchable
|
|
def greet(self, name):
|
|
f = wireproto.future()
|
|
yield {"name": mangle(name)}, f
|
|
yield unmangle(pycompat.decodeutf8(f.value))
|
|
|
|
|
|
class serverrepo(object):
|
|
def __init__(self):
|
|
self.ui = ui.ui()
|
|
|
|
def greet(self, name):
|
|
return "Hello, " + name
|
|
|
|
def filtered(self, name):
|
|
return self
|
|
|
|
|
|
def mangle(s):
|
|
return "".join(chr(ord(c) + 1) for c in s)
|
|
|
|
|
|
def unmangle(s):
|
|
return "".join(chr(ord(c) - 1) for c in s)
|
|
|
|
|
|
def greet(repo, proto, name):
|
|
return mangle(repo.greet(unmangle(name)))
|
|
|
|
|
|
wireproto.commands["greet"] = (greet, "name")
|
|
|
|
srv = serverrepo()
|
|
clt = clientpeer(srv)
|
|
|
|
print(clt.greet("Foobar"))
|
|
b = clt.iterbatch()
|
|
list(map(b.greet, ("Fo, =;:<o", "Bar")))
|
|
b.submit()
|
|
print([r for r in b.results()])
|