Mercurial > hg
view tests/test-wireproto.py @ 19091:f01a351db791 stable
win32: use explicit path to "python.exe" only if it exists
Before this patch, "hg.bat" for Windows environment always uses
"%~dp0..\python" as explicit path to "python.exe".
This path may not be valid in some cases.
For example, on the environment using "virtualenv" python package,
both "python.exe" and "hg.bat" are placed in the same directory. In
this case, "python.exe" should be found on PATH, because virtualenv
activation script puts "python.exe" on the PATH.
This patch uses explicit path to "python.exe" only if it exists, and
expects that "python.exe" can be found on PATH otherwise.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 26 Apr 2013 01:12:03 +0900 |
parents | 753acee7d6dd |
children | c69f62906358 |
line wrap: on
line source
from mercurial import wireproto 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 def _call(self, cmd, **args): return wireproto.dispatch(self.serverrepo, proto(args), cmd) @wireproto.batchable def greet(self, name): f = wireproto.future() yield wireproto.todict(name=mangle(name)), f yield unmangle(f.value) class serverrepo(object): 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.batch() fs = [b.greet(s) for s in ["Fo, =;o", "Bar"]] b.submit() print [f.value for f in fs]