mercurial/debugcommands.py
changeset 36530 bde0bd50f368
parent 36528 72e487851a53
child 36531 097ad1079192
equal deleted inserted replaced
36529:33c6f8f0388d 36530:bde0bd50f368
  2612     raw+
  2612     raw+
  2613     ----
  2613     ----
  2614 
  2614 
  2615     Behaves like ``raw`` except flushes output afterwards.
  2615     Behaves like ``raw`` except flushes output afterwards.
  2616 
  2616 
       
  2617     command <X>
       
  2618     -----------
       
  2619 
       
  2620     Send a request to run a named command, whose name follows the ``command``
       
  2621     string.
       
  2622 
       
  2623     Arguments to the command are defined as lines in this block. The format of
       
  2624     each line is ``<key> <value>``. e.g.::
       
  2625 
       
  2626        command listkeys
       
  2627            namespace bookmarks
       
  2628 
       
  2629     Values are interpreted as Python b'' literals. This allows encoding
       
  2630     special byte sequences via backslash escaping.
       
  2631 
  2617     close
  2632     close
  2618     -----
  2633     -----
  2619 
  2634 
  2620     Close the connection to the server.
  2635     Close the connection to the server.
  2621 
  2636 
  2711 
  2726 
  2712             if action == 'raw+':
  2727             if action == 'raw+':
  2713                 stdin.flush()
  2728                 stdin.flush()
  2714         elif action == 'flush':
  2729         elif action == 'flush':
  2715             stdin.flush()
  2730             stdin.flush()
       
  2731         elif action.startswith('command'):
       
  2732             if not peer:
       
  2733                 raise error.Abort(_('cannot send commands unless peer instance '
       
  2734                                     'is available'))
       
  2735 
       
  2736             command = action.split(' ', 1)[1]
       
  2737 
       
  2738             args = {}
       
  2739             for line in lines:
       
  2740                 # We need to allow empty values.
       
  2741                 fields = line.lstrip().split(' ', 1)
       
  2742                 if len(fields) == 1:
       
  2743                     key = fields[0]
       
  2744                     value = ''
       
  2745                 else:
       
  2746                     key, value = fields
       
  2747 
       
  2748                 args[key] = util.unescapestr(value)
       
  2749 
       
  2750             ui.status(_('sending %s command\n') % command)
       
  2751             res = peer._call(command, **args)
       
  2752             ui.status(_('response: %s\n') % util.escapedata(res))
       
  2753 
  2716         elif action == 'close':
  2754         elif action == 'close':
  2717             peer.close()
  2755             peer.close()
  2718         elif action == 'readavailable':
  2756         elif action == 'readavailable':
  2719             fds = util.poll([stdout.fileno(), stderr.fileno()])
  2757             fds = util.poll([stdout.fileno(), stderr.fileno()])
  2720 
  2758