Mercurial > public > mercurial-scm > hg
diff mercurial/wireproto.py @ 11584:1af96b090116
protocol: unify changegroup commands
- add sendchangegroup protocol helpers
- handle commands with None results
- move changegroup commands into wireproto.py
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 14 Jul 2010 15:43:20 -0500 |
parents | 944c23762c3c |
children | 5d907fbb9703 |
line wrap: on
line diff
--- a/mercurial/wireproto.py Wed Jul 14 15:33:21 2010 -0500 +++ b/mercurial/wireproto.py Wed Jul 14 15:43:20 2010 -0500 @@ -15,7 +15,9 @@ return False func, spec = commands[command] args = proto.getargs(spec) - proto.respond(func(repo, proto, *args)) + r = func(repo, proto, *args) + if r != None: + proto.respond(r) return True def between(repo, proto, pairs): @@ -41,6 +43,17 @@ r.append(" ".join(map(hex, b)) + "\n") return "".join(r) +def changegroup(repo, proto, roots): + nodes = map(bin, roots.split(" ")) + cg = repo.changegroup(nodes, 'serve') + proto.sendchangegroup(cg) + +def changegroupsubset(repo, proto, bases, heads): + bases = [bin(n) for n in bases.split(' ')] + heads = [bin(n) for n in heads.split(' ')] + cg = repo.changegroupsubset(bases, heads, 'serve') + proto.sendchangegroup(cg) + def heads(repo, proto): h = repo.heads() return " ".join(map(hex, h)) + "\n" @@ -68,6 +81,8 @@ 'between': (between, 'pairs'), 'branchmap': (branchmap, ''), 'branches': (branches, 'nodes'), + 'changegroup': (changegroup, 'roots'), + 'changegroupsubset': (changegroupsubset, 'bases heads'), 'heads': (heads, ''), 'listkeys': (listkeys, 'namespace'), 'lookup': (lookup, 'key'),