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