158 |
158 |
159 def dispatch(repo, proto, command): |
159 def dispatch(repo, proto, command): |
160 func, spec = commands[command] |
160 func, spec = commands[command] |
161 args = proto.getargs(spec) |
161 args = proto.getargs(spec) |
162 return func(repo, proto, *args) |
162 return func(repo, proto, *args) |
|
163 |
|
164 def options(cmd, keys, others): |
|
165 opts = {} |
|
166 for k in keys: |
|
167 if k in others: |
|
168 opts[k] = others[k] |
|
169 del others[k] |
|
170 if others: |
|
171 sys.stderr.write("abort: %s got unexpected arguments %s\n" |
|
172 % (cmd, ",".join(others))) |
|
173 return opts |
163 |
174 |
164 def between(repo, proto, pairs): |
175 def between(repo, proto, pairs): |
165 pairs = [decodelist(p, '-') for p in pairs.split(" ")] |
176 pairs = [decodelist(p, '-') for p in pairs.split(" ")] |
166 r = [] |
177 r = [] |
167 for b in repo.between(pairs): |
178 for b in repo.between(pairs): |
206 bases = decodelist(bases) |
217 bases = decodelist(bases) |
207 heads = decodelist(heads) |
218 heads = decodelist(heads) |
208 cg = repo.changegroupsubset(bases, heads, 'serve') |
219 cg = repo.changegroupsubset(bases, heads, 'serve') |
209 return streamres(proto.groupchunks(cg)) |
220 return streamres(proto.groupchunks(cg)) |
210 |
221 |
211 def debugwireargs(repo, proto, one, two): |
222 def debugwireargs(repo, proto, one, two, others): |
212 return repo.debugwireargs(one, two) |
223 # only accept optional args from the known set |
|
224 opts = options('debugwireargs', ['three', 'four'], others) |
|
225 return repo.debugwireargs(one, two, **opts) |
213 |
226 |
214 def heads(repo, proto): |
227 def heads(repo, proto): |
215 h = repo.heads() |
228 h = repo.heads() |
216 return encodelist(h) + "\n" |
229 return encodelist(h) + "\n" |
217 |
230 |
353 'branchmap': (branchmap, ''), |
366 'branchmap': (branchmap, ''), |
354 'branches': (branches, 'nodes'), |
367 'branches': (branches, 'nodes'), |
355 'capabilities': (capabilities, ''), |
368 'capabilities': (capabilities, ''), |
356 'changegroup': (changegroup, 'roots'), |
369 'changegroup': (changegroup, 'roots'), |
357 'changegroupsubset': (changegroupsubset, 'bases heads'), |
370 'changegroupsubset': (changegroupsubset, 'bases heads'), |
358 'debugwireargs': (debugwireargs, 'one two'), |
371 'debugwireargs': (debugwireargs, 'one two *'), |
359 'heads': (heads, ''), |
372 'heads': (heads, ''), |
360 'hello': (hello, ''), |
373 'hello': (hello, ''), |
361 'listkeys': (listkeys, 'namespace'), |
374 'listkeys': (listkeys, 'namespace'), |
362 'lookup': (lookup, 'key'), |
375 'lookup': (lookup, 'key'), |
363 'pushkey': (pushkey, 'namespace key old new'), |
376 'pushkey': (pushkey, 'namespace key old new'), |