Mercurial > hg
view tests/test-wireproto.py @ 27920:da5f23362517 stable
changegroup: cg3 has two empty groups *after* manifests
changegroup.getchunks() determines the end of the stream by looking
for an empty chunk group (two consecutive empty chunks). It ignores
empty groups in the first two groups. Changegroup 3 introduced an
empty chunk between the manifests and the files, which confuses
getchunks(). Since it comes after the first two, getchunks() will stop
there.
Fix by rewriting getchunks so it first counts two groups (empty or
not) and then keeps antostarts counting empty groups. With this counting,
changegroup 1 and 2 have exactly one empty group after the first two
groups, while changegroup 3 has two (one for directories and one for
files).
It's a little hard to test this at this point, but I have verified
that this patch fixes narrowhg (which was broken before this
patch). Also, future patches will fix "hg strip" with treemanifests,
and once that's done, getchunks() will be tested through tests of "hg
strip".
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 19 Jan 2016 17:44:25 -0800 |
parents | 5defcb7d6e5f |
children | 48fd02dac1d4 |
line wrap: on
line source
from __future__ import absolute_import 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 _capabilities(self): return ['batch'] def _call(self, cmd, **args): return wireproto.dispatch(self.serverrepo, proto(args), cmd) @wireproto.batchable def greet(self, name): f = wireproto.future() yield {'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]