67 return repo.filtered('served') |
67 return repo.filtered('served') |
68 |
68 |
69 def dispatch(repo, proto, command): |
69 def dispatch(repo, proto, command): |
70 repo = getdispatchrepo(repo, proto, command) |
70 repo = getdispatchrepo(repo, proto, command) |
71 |
71 |
72 transportversion = wireprototypes.TRANSPORTS[proto.name]['version'] |
72 func, spec = commands[command] |
73 commandtable = commandsv2 if transportversion == 2 else commands |
|
74 func, spec = commandtable[command] |
|
75 |
|
76 args = proto.getargs(spec) |
73 args = proto.getargs(spec) |
77 |
74 |
78 # Version 1 protocols define arguments as a list. Version 2 uses a dict. |
75 return func(repo, proto, *args) |
79 if isinstance(args, list): |
|
80 return func(repo, proto, *args) |
|
81 elif isinstance(args, dict): |
|
82 return func(repo, proto, **args) |
|
83 else: |
|
84 raise error.ProgrammingError('unexpected type returned from ' |
|
85 'proto.getargs(): %s' % type(args)) |
|
86 |
76 |
87 def options(cmd, keys, others): |
77 def options(cmd, keys, others): |
88 opts = {} |
78 opts = {} |
89 for k in keys: |
79 for k in keys: |
90 if k in others: |
80 if k in others: |