Show More
@@ -5536,7 +5536,7 b' def serve(ui, repo, **opts):' | |||||
5536 | s.serve_forever() |
|
5536 | s.serve_forever() | |
5537 |
|
5537 | |||
5538 | if opts["cmdserver"]: |
|
5538 | if opts["cmdserver"]: | |
5539 |
service = commandserver. |
|
5539 | service = commandserver.createservice(ui, repo, opts) | |
5540 | return cmdutil.service(opts, initfn=service.init, runfn=service.run) |
|
5540 | return cmdutil.service(opts, initfn=service.init, runfn=service.run) | |
5541 |
|
5541 | |||
5542 | # this way we can check if something was given in the command-line |
|
5542 | # this way we can check if something was given in the command-line |
@@ -129,7 +129,7 b' class server(object):' | |||||
129 | Listens for commands on stdin, runs them and writes the output on a channel |
|
129 | Listens for commands on stdin, runs them and writes the output on a channel | |
130 | based stream to stdout. |
|
130 | based stream to stdout. | |
131 | """ |
|
131 | """ | |
132 |
def __init__(self, ui, repo |
|
132 | def __init__(self, ui, repo): | |
133 | self.cwd = os.getcwd() |
|
133 | self.cwd = os.getcwd() | |
134 |
|
134 | |||
135 | logpath = ui.config("cmdserver", "log", None) |
|
135 | logpath = ui.config("cmdserver", "log", None) | |
@@ -151,15 +151,12 b' class server(object):' | |||||
151 | self.ui = ui |
|
151 | self.ui = ui | |
152 | self.repo = self.repoui = None |
|
152 | self.repo = self.repoui = None | |
153 |
|
153 | |||
154 | if mode == 'pipe': |
|
154 | self.cerr = channeledoutput(sys.stdout, 'e') | |
155 |
|
|
155 | self.cout = channeledoutput(sys.stdout, 'o') | |
156 |
|
|
156 | self.cin = channeledinput(sys.stdin, sys.stdout, 'I') | |
157 |
|
|
157 | self.cresult = channeledoutput(sys.stdout, 'r') | |
158 | self.cresult = channeledoutput(sys.stdout, 'r') |
|
|||
159 |
|
158 | |||
160 |
|
|
159 | self.client = sys.stdin | |
161 | else: |
|
|||
162 | raise util.Abort(_('unknown mode %s') % mode) |
|
|||
163 |
|
160 | |||
164 | def _read(self, size): |
|
161 | def _read(self, size): | |
165 | if not size: |
|
162 | if not size: | |
@@ -251,10 +248,21 b' class server(object):' | |||||
251 |
|
248 | |||
252 | class pipeservice(object): |
|
249 | class pipeservice(object): | |
253 | def __init__(self, ui, repo, opts): |
|
250 | def __init__(self, ui, repo, opts): | |
254 |
self.server = server(ui, repo |
|
251 | self.server = server(ui, repo) | |
255 |
|
252 | |||
256 | def init(self): |
|
253 | def init(self): | |
257 | pass |
|
254 | pass | |
258 |
|
255 | |||
259 | def run(self): |
|
256 | def run(self): | |
260 | return self.server.serve() |
|
257 | return self.server.serve() | |
|
258 | ||||
|
259 | _servicemap = { | |||
|
260 | 'pipe': pipeservice, | |||
|
261 | } | |||
|
262 | ||||
|
263 | def createservice(ui, repo, opts): | |||
|
264 | mode = opts['cmdserver'] | |||
|
265 | try: | |||
|
266 | return _servicemap[mode](ui, repo, opts) | |||
|
267 | except KeyError: | |||
|
268 | raise util.Abort(_('unknown mode %s') % mode) |
General Comments 0
You need to be logged in to leave comments.
Login now