Mercurial > hg
comparison mercurial/wireproto.py @ 11594:67863f9d805f
protocol: unify server-side capabilities functions
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 15 Jul 2010 13:56:52 -0500 |
parents | d054cc5c7737 |
children | 9141d2c9e5a5 |
comparison
equal
deleted
inserted
replaced
11593:d054cc5c7737 | 11594:67863f9d805f |
---|---|
157 r = [] | 157 r = [] |
158 for b in repo.branches(nodes): | 158 for b in repo.branches(nodes): |
159 r.append(" ".join(map(hex, b)) + "\n") | 159 r.append(" ".join(map(hex, b)) + "\n") |
160 return "".join(r) | 160 return "".join(r) |
161 | 161 |
162 def capabilities(repo, proto): | |
163 caps = 'lookup changegroupsubset branchmap pushkey'.split() | |
164 if streamclone.allowed(repo.ui): | |
165 caps.append('stream=%d' % repo.changelog.version) | |
166 caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority)) | |
167 return ' '.join(caps) | |
168 | |
162 def changegroup(repo, proto, roots): | 169 def changegroup(repo, proto, roots): |
163 nodes = map(bin, roots.split(" ")) | 170 nodes = map(bin, roots.split(" ")) |
164 cg = repo.changegroup(nodes, 'serve') | 171 cg = repo.changegroup(nodes, 'serve') |
165 proto.sendchangegroup(cg) | 172 proto.sendchangegroup(cg) |
166 | 173 |
171 proto.sendchangegroup(cg) | 178 proto.sendchangegroup(cg) |
172 | 179 |
173 def heads(repo, proto): | 180 def heads(repo, proto): |
174 h = repo.heads() | 181 h = repo.heads() |
175 return " ".join(map(hex, h)) + "\n" | 182 return " ".join(map(hex, h)) + "\n" |
183 | |
184 def hello(repo, proto): | |
185 '''the hello command returns a set of lines describing various | |
186 interesting things about the server, in an RFC822-like format. | |
187 Currently the only one defined is "capabilities", which | |
188 consists of a line in the form: | |
189 | |
190 capabilities: space separated list of tokens | |
191 ''' | |
192 return "capabilities: %s\n" % (capabilities(repo, proto)) | |
176 | 193 |
177 def listkeys(repo, proto, namespace): | 194 def listkeys(repo, proto, namespace): |
178 d = pushkey_.list(repo, namespace).items() | 195 d = pushkey_.list(repo, namespace).items() |
179 t = '\n'.join(['%s\t%s' % (k.encode('string-escape'), | 196 t = '\n'.join(['%s\t%s' % (k.encode('string-escape'), |
180 v.encode('string-escape')) for k, v in d]) | 197 v.encode('string-escape')) for k, v in d]) |
251 | 268 |
252 commands = { | 269 commands = { |
253 'between': (between, 'pairs'), | 270 'between': (between, 'pairs'), |
254 'branchmap': (branchmap, ''), | 271 'branchmap': (branchmap, ''), |
255 'branches': (branches, 'nodes'), | 272 'branches': (branches, 'nodes'), |
273 'capabilities': (capabilities, ''), | |
256 'changegroup': (changegroup, 'roots'), | 274 'changegroup': (changegroup, 'roots'), |
257 'changegroupsubset': (changegroupsubset, 'bases heads'), | 275 'changegroupsubset': (changegroupsubset, 'bases heads'), |
258 'heads': (heads, ''), | 276 'heads': (heads, ''), |
277 'hello': (hello, ''), | |
259 'listkeys': (listkeys, 'namespace'), | 278 'listkeys': (listkeys, 'namespace'), |
260 'lookup': (lookup, 'key'), | 279 'lookup': (lookup, 'key'), |
261 'pushkey': (pushkey, 'namespace key old new'), | 280 'pushkey': (pushkey, 'namespace key old new'), |
262 'stream_out': (stream, ''), | 281 'stream_out': (stream, ''), |
263 'unbundle': (unbundle, 'heads'), | 282 'unbundle': (unbundle, 'heads'), |