mercurial/wireproto.py
changeset 20906 7a634b34fc91
parent 20905 167047ba3cfa
child 20907 aedec880e095
equal deleted inserted replaced
20905:167047ba3cfa 20906:7a634b34fc91
   469     if others:
   469     if others:
   470         sys.stderr.write("abort: %s got unexpected arguments %s\n"
   470         sys.stderr.write("abort: %s got unexpected arguments %s\n"
   471                          % (cmd, ",".join(others)))
   471                          % (cmd, ",".join(others)))
   472     return opts
   472     return opts
   473 
   473 
       
   474 # list of commands
       
   475 commands = {}
       
   476 
       
   477 def wireprotocommand(name, args=''):
       
   478     """decorator for wireprotocol command"""
       
   479     def register(func):
       
   480         commands[name] = (func, args)
       
   481         return func
       
   482     return register
       
   483 
   474 def batch(repo, proto, cmds, others):
   484 def batch(repo, proto, cmds, others):
   475     repo = repo.filtered("served")
   485     repo = repo.filtered("served")
   476     res = []
   486     res = []
   477     for pair in cmds.split(';'):
   487     for pair in cmds.split(';'):
   478         op, args = pair.split(' ', 1)
   488         op, args = pair.split(' ', 1)
   768 
   778 
   769     finally:
   779     finally:
   770         fp.close()
   780         fp.close()
   771         os.unlink(tempname)
   781         os.unlink(tempname)
   772 
   782 
   773 commands = {
   783 commands.update({
   774     'batch': (batch, 'cmds *'),
   784     'batch': (batch, 'cmds *'),
   775     'between': (between, 'pairs'),
   785     'between': (between, 'pairs'),
   776     'branchmap': (branchmap, ''),
   786     'branchmap': (branchmap, ''),
   777     'branches': (branches, 'nodes'),
   787     'branches': (branches, 'nodes'),
   778     'capabilities': (capabilities, ''),
   788     'capabilities': (capabilities, ''),
   786     'listkeys': (listkeys, 'namespace'),
   796     'listkeys': (listkeys, 'namespace'),
   787     'lookup': (lookup, 'key'),
   797     'lookup': (lookup, 'key'),
   788     'pushkey': (pushkey, 'namespace key old new'),
   798     'pushkey': (pushkey, 'namespace key old new'),
   789     'stream_out': (stream, ''),
   799     'stream_out': (stream, ''),
   790     'unbundle': (unbundle, 'heads'),
   800     'unbundle': (unbundle, 'heads'),
   791 }
   801 })