Skip to content
Snippets Groups Projects
Commit 000cfc8b authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

cmdserver: use given streams as pipe channels like other commands

Because commandserver itself is an hg subcommand, it shouldn't use stdio
directly in principle.
parent d716b1ce
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
from i18n import _
import struct
import sys, os, errno, traceback, SocketServer
import os, errno, traceback, SocketServer
import dispatch, encoding, util
logfile = None
......@@ -250,7 +250,7 @@
class pipeservice(object):
def __init__(self, ui, repo, opts):
self.server = server(ui, repo, sys.stdin, sys.stdout)
self.server = server(ui, repo, ui.fin, ui.fout)
def init(self):
pass
......
......@@ -524,6 +524,27 @@
prompt: 5678
run commandserver in commandserver, which is silly but should work:
>>> import cStringIO
>>> from hgclient import readchannel, runcommand, check
>>> @check
... def nested(server):
... print '%c, %r' % readchannel(server)
... class nestedserver(object):
... stdin = cStringIO.StringIO('getencoding\n')
... stdout = cStringIO.StringIO()
... runcommand(server, ['serve', '--cmdserver', 'pipe'],
... output=nestedserver.stdout, input=nestedserver.stdin)
... nestedserver.stdout.seek(0)
... print '%c, %r' % readchannel(nestedserver) # hello
... print '%c, %r' % readchannel(nestedserver) # getencoding
o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
*** runcommand serve --cmdserver pipe
o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
r, '*' (glob)
start without repository:
$ cd ..
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment