330 for ui in uis: |
330 for ui in uis: |
331 ui.resetstate() |
331 ui.resetstate() |
332 # any kind of interaction must use server channels, but chg may |
332 # any kind of interaction must use server channels, but chg may |
333 # replace channels by fully functional tty files. so nontty is |
333 # replace channels by fully functional tty files. so nontty is |
334 # enforced only if cin is a channel. |
334 # enforced only if cin is a channel. |
335 if not util.safehasattr(self.cin, 'fileno'): |
335 if not hasattr(self.cin, 'fileno'): |
336 ui.setconfig(b'ui', b'nontty', b'true', b'commandserver') |
336 ui.setconfig(b'ui', b'nontty', b'true', b'commandserver') |
337 |
337 |
338 req = dispatch.request( |
338 req = dispatch.request( |
339 args[:], |
339 args[:], |
340 copiedui, |
340 copiedui, |
382 hellomsg += b'encoding: ' + encoding.encoding |
382 hellomsg += b'encoding: ' + encoding.encoding |
383 hellomsg += b'\n' |
383 hellomsg += b'\n' |
384 if self.cmsg: |
384 if self.cmsg: |
385 hellomsg += b'message-encoding: %s\n' % self.cmsg.encoding |
385 hellomsg += b'message-encoding: %s\n' % self.cmsg.encoding |
386 hellomsg += b'pid: %d' % procutil.getpid() |
386 hellomsg += b'pid: %d' % procutil.getpid() |
387 if util.safehasattr(os, 'getpgid'): |
387 if hasattr(os, 'getpgid'): |
388 hellomsg += b'\n' |
388 hellomsg += b'\n' |
389 hellomsg += b'pgid: %d' % os.getpgid(0) |
389 hellomsg += b'pgid: %d' % os.getpgid(0) |
390 |
390 |
391 # write the hello msg in -one- chunk |
391 # write the hello msg in -one- chunk |
392 self.cout.write(hellomsg) |
392 self.cout.write(hellomsg) |
557 |
557 |
558 def __init__(self, ui, repo, opts, handler=None): |
558 def __init__(self, ui, repo, opts, handler=None): |
559 self.ui = ui |
559 self.ui = ui |
560 self.repo = repo |
560 self.repo = repo |
561 self.address = opts[b'address'] |
561 self.address = opts[b'address'] |
562 if not util.safehasattr(socket, 'AF_UNIX'): |
562 if not hasattr(socket, 'AF_UNIX'): |
563 raise error.Abort(_(b'unsupported platform')) |
563 raise error.Abort(_(b'unsupported platform')) |
564 if not self.address: |
564 if not self.address: |
565 raise error.Abort(_(b'no socket path specified with --address')) |
565 raise error.Abort(_(b'no socket path specified with --address')) |
566 self._servicehandler = handler or unixservicehandler(ui) |
566 self._servicehandler = handler or unixservicehandler(ui) |
567 self._sock = None |
567 self._sock = None |
586 # a uni-directional pipe, but is backed by a DGRAM socket so each |
586 # a uni-directional pipe, but is backed by a DGRAM socket so each |
587 # message can be easily separated. |
587 # message can be easily separated. |
588 o = socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM) |
588 o = socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM) |
589 self._mainipc, self._workeripc = o |
589 self._mainipc, self._workeripc = o |
590 self._servicehandler.bindsocket(self._sock, self.address) |
590 self._servicehandler.bindsocket(self._sock, self.address) |
591 if util.safehasattr(procutil, 'unblocksignal'): |
591 if hasattr(procutil, 'unblocksignal'): |
592 procutil.unblocksignal(signal.SIGCHLD) |
592 procutil.unblocksignal(signal.SIGCHLD) |
593 o = signal.signal(signal.SIGCHLD, self._sigchldhandler) |
593 o = signal.signal(signal.SIGCHLD, self._sigchldhandler) |
594 self._oldsigchldhandler = o |
594 self._oldsigchldhandler = o |
595 self._socketunlinked = False |
595 self._socketunlinked = False |
596 self._repoloader.start() |
596 self._repoloader.start() |