Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/protocol.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 | 26c7d4fc31bf |
children | 5d907fbb9703 |
comparison
equal
deleted
inserted
replaced
11583:944c23762c3c | 11584:1af96b090116 |
---|---|
20 'branchmap', 'pushkey', 'listkeys' | 20 'branchmap', 'pushkey', 'listkeys' |
21 ] | 21 ] |
22 | 22 |
23 HGTYPE = 'application/mercurial-0.1' | 23 HGTYPE = 'application/mercurial-0.1' |
24 basecaps = 'lookup changegroupsubset branchmap pushkey'.split() | 24 basecaps = 'lookup changegroupsubset branchmap pushkey'.split() |
25 | |
26 def changegroup(repo, req): | |
27 req.respond(HTTP_OK, HGTYPE) | |
28 nodes = [] | |
29 | |
30 if 'roots' in req.form: | |
31 nodes = map(bin, req.form['roots'][0].split(" ")) | |
32 | |
33 z = zlib.compressobj() | |
34 f = repo.changegroup(nodes, 'serve') | |
35 while 1: | |
36 chunk = f.read(4096) | |
37 if not chunk: | |
38 break | |
39 yield z.compress(chunk) | |
40 | |
41 yield z.flush() | |
42 | |
43 def changegroupsubset(repo, req): | |
44 req.respond(HTTP_OK, HGTYPE) | |
45 bases = [] | |
46 heads = [] | |
47 | |
48 if 'bases' in req.form: | |
49 bases = [bin(x) for x in req.form['bases'][0].split(' ')] | |
50 if 'heads' in req.form: | |
51 heads = [bin(x) for x in req.form['heads'][0].split(' ')] | |
52 | |
53 z = zlib.compressobj() | |
54 f = repo.changegroupsubset(bases, heads, 'serve') | |
55 while 1: | |
56 chunk = f.read(4096) | |
57 if not chunk: | |
58 break | |
59 yield z.compress(chunk) | |
60 | |
61 yield z.flush() | |
62 | 25 |
63 def capabilities(repo, req): | 26 def capabilities(repo, req): |
64 caps = copy.copy(basecaps) | 27 caps = copy.copy(basecaps) |
65 if streamclone.allowed(repo.ui): | 28 if streamclone.allowed(repo.ui): |
66 caps.append('stream=%d' % repo.changelog.version) | 29 caps.append('stream=%d' % repo.changelog.version) |