/** * Starts a Mercurial process which can actually handle requests. * * @return ArcanistHgServerChannel Channel to the Mercurial server. * @task hg */ private function startMercurialProcess() { // NOTE: "cmdserver.log=-" makes Mercurial use the 'd'ebug channel for // log messages. $future = new ExecFuture('HGPLAIN=1 hg --config cmdserver.log=- serve --cmdserver pipe'); $future->setCWD($this->workingCopy); $channel = new PhutilExecChannel($future); $hg = new ArcanistHgServerChannel($channel); // The server sends a "hello" message with capability and encoding // information. Save it and forward it to clients when they connect. $this->hello = $hg->waitForMessage(); return $hg; }
/** * @task internal */ private function connectToDaemon() { $errno = null; $errstr = null; $socket_path = ArcanistHgProxyServer::getPathToSocket($this->workingCopy); $socket = @stream_socket_client('unix://' . $socket_path, $errno, $errstr); if ($errno || !$socket) { throw new Exception("Unable to connect socket! Error #{$errno}: {$errstr}"); } $channel = new PhutilSocketChannel($socket); $server = new ArcanistHgServerChannel($channel); if (!$this->skipHello) { // The protocol includes a "hello" message with capability and encoding // information. Read and discard it, we use only the "runcommand" // capability which is guaranteed to be available. $hello = $server->waitForMessage(); } return $server; }