Show More
@@ -311,6 +311,7 b' class chgcmdserver(commandserver.server)' | |||||
311 | _newchgui(ui, channeledsystem(fin, fout, 'S'), self.attachio), |
|
311 | _newchgui(ui, channeledsystem(fin, fout, 'S'), self.attachio), | |
312 | repo, fin, fout) |
|
312 | repo, fin, fout) | |
313 | self.clientsock = sock |
|
313 | self.clientsock = sock | |
|
314 | self._ioattached = False | |||
314 | self._oldios = [] # original (self.ch, ui.fp, fd) before "attachio" |
|
315 | self._oldios = [] # original (self.ch, ui.fp, fd) before "attachio" | |
315 | self.hashstate = hashstate |
|
316 | self.hashstate = hashstate | |
316 | self.baseaddress = baseaddress |
|
317 | self.baseaddress = baseaddress | |
@@ -324,6 +325,7 b' class chgcmdserver(commandserver.server)' | |||||
324 | # handled by dispatch._dispatch() |
|
325 | # handled by dispatch._dispatch() | |
325 | self.ui.flush() |
|
326 | self.ui.flush() | |
326 | self._restoreio() |
|
327 | self._restoreio() | |
|
328 | self._ioattached = False | |||
327 |
|
329 | |||
328 | def attachio(self): |
|
330 | def attachio(self): | |
329 | """Attach to client's stdio passed via unix domain socket; all |
|
331 | """Attach to client's stdio passed via unix domain socket; all | |
@@ -337,13 +339,13 b' class chgcmdserver(commandserver.server)' | |||||
337 |
|
339 | |||
338 | ui = self.ui |
|
340 | ui = self.ui | |
339 | ui.flush() |
|
341 | ui.flush() | |
340 |
|
|
342 | self._saveio() | |
341 | for fd, (cn, fn, mode) in zip(clientfds, _iochannels): |
|
343 | for fd, (cn, fn, mode) in zip(clientfds, _iochannels): | |
342 | assert fd > 0 |
|
344 | assert fd > 0 | |
343 | fp = getattr(ui, fn) |
|
345 | fp = getattr(ui, fn) | |
344 | os.dup2(fd, fp.fileno()) |
|
346 | os.dup2(fd, fp.fileno()) | |
345 | os.close(fd) |
|
347 | os.close(fd) | |
346 |
if |
|
348 | if self._ioattached: | |
347 | continue |
|
349 | continue | |
348 | # reset buffering mode when client is first attached. as we want |
|
350 | # reset buffering mode when client is first attached. as we want | |
349 | # to see output immediately on pager, the mode stays unchanged |
|
351 | # to see output immediately on pager, the mode stays unchanged | |
@@ -362,18 +364,18 b' class chgcmdserver(commandserver.server)' | |||||
362 | setattr(ui, fn, newfp) |
|
364 | setattr(ui, fn, newfp) | |
363 | setattr(self, cn, newfp) |
|
365 | setattr(self, cn, newfp) | |
364 |
|
366 | |||
|
367 | self._ioattached = True | |||
365 | self.cresult.write(struct.pack('>i', len(clientfds))) |
|
368 | self.cresult.write(struct.pack('>i', len(clientfds))) | |
366 |
|
369 | |||
367 | def _saveio(self): |
|
370 | def _saveio(self): | |
368 | if self._oldios: |
|
371 | if self._oldios: | |
369 |
return |
|
372 | return | |
370 | ui = self.ui |
|
373 | ui = self.ui | |
371 | for cn, fn, _mode in _iochannels: |
|
374 | for cn, fn, _mode in _iochannels: | |
372 | ch = getattr(self, cn) |
|
375 | ch = getattr(self, cn) | |
373 | fp = getattr(ui, fn) |
|
376 | fp = getattr(ui, fn) | |
374 | fd = os.dup(fp.fileno()) |
|
377 | fd = os.dup(fp.fileno()) | |
375 | self._oldios.append((ch, fp, fd)) |
|
378 | self._oldios.append((ch, fp, fd)) | |
376 | return True |
|
|||
377 |
|
379 | |||
378 | def _restoreio(self): |
|
380 | def _restoreio(self): | |
379 | ui = self.ui |
|
381 | ui = self.ui |
General Comments 0
You need to be logged in to leave comments.
Login now