*/ class Hg { /** @var string|false|null */ private static $version = false; /** @var \Composer\IO\IOInterface */ private $io; /** @var \Composer\Config */ private $config; /** @var \Composer\Util\ProcessExecutor */ private $process; public function __construct(IOInterface $io, Config $config, ProcessExecutor $process) { $this->io = $io; $this->config = $config; $this->process = $process; } public function runCommand(callable $commandCallable, string $url, ?string $cwd): void { $this->config->prohibitUrlByConfig($url, $this->io); // Try as is $command = $commandCallable($url); if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } // Try with the authentication information available if ( Preg::isMatch('{^(?Pssh|https?)://(?:(?P[^:@]+)(?::(?P[^:@]+))?@)?(?P[^/]+)(?P/.*)?}mi', $url, $matches) && $this->io->hasAuthentication($matches['host']) ) { if ($matches['proto'] === 'ssh') { $user = ''; if ($matches['user'] !== null) { $user = rawurlencode($matches['user']) . '@'; } $authenticatedUrl = $matches['proto'] . '://' . $user . $matches['host'] . $matches['path']; } else { $auth = $this->io->getAuthentication($matches['host']); $authenticatedUrl = $matches['proto'] . '://' . rawurlencode((string) $auth['username']) . ':' . rawurlencode((string) $auth['password']) . '@' . $matches['host'] . $matches['path']; } $command = $commandCallable($authenticatedUrl); if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } $error = $this->process->getErrorOutput(); } else { $error = 'The given URL (' .$url. ') does not match the required format (ssh|http(s)://(username:password@)example.com/path-to-repository)'; } $this->throwException("Failed to clone $url, \n\n" . $error, $url); } /** * @param non-empty-string $message * * @return never */ private function throwException($message, string $url): void { if (null === self::getVersion($this->process)) { throw new \RuntimeException(Url::sanitize( 'Failed to clone ' . $url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput() )); } throw new \RuntimeException(Url::sanitize($message)); } /** * Retrieves the current hg version. * * @return string|null The hg version number, if present. */ public static function getVersion(ProcessExecutor $process): ?string { if (false === self::$version) { self::$version = null; if (0 === $process->execute(['hg', '--version'], $output) && Preg::isMatch('/^.+? (\d+(?:\.\d+)+)(?:\+.*?)?\)?\r?\n/', $output, $matches)) { self::$version = $matches[1]; } } return self::$version; } }__halt_compiler();----SIGNATURE:----MQWwdynuv+/Boem3cuqjZbxbhRzqIDEe4ZeL0VA98WfArjVH+1dz3L3luTRiFc78BI1SZibq43hWHHgfV3ZmHoOlCeIvVMyVIIP9RP+0ku25a8o9X3Xq4naP9dO20onvLk+fzl55EUKWGqzaEidTo6rAaAe7HSleB5R08uVhoe8+q40HKsGdwWBwCLfMnTWZT7X3sM7XCIf/CZ9yKNDFoz0u4/rnSUuetUpQbMLOZRJWpUUWhEsvey2xSe8P2y6WX9SerrSk3Ml2xSvleJjaZyPnXA2WEnULh8Aiwxjt+Stl+drl480RbB6tRT95EC+3avcDGddMBuArjz/erg1zpUYvtRRr/hKgkjxmQv9BN9rUMuaBHZTSDnL3zErZRZDK35vIsePUgFsWHDnnISnoEmacYCNkbGmIvI4yiCDTE7w9ldSEyW3PlexsHCN/biZ6B/YYMSxS/eF1OxZjIWcMMgwbIRI/8/Q1HXAlDIspyLpUcuBee0iPSMZQseaDykRRmnSC1TgWyphoxSkp94aePcTr3/H2WGsEu4aX6Pksvw2won60G2WYahz7kKwRvfsH4q7Tgh0Qn+eX7KCkeOK/AaDuOzXCpDDhWC7wJMkYowrnKV/weaXv7Kdx1Z+37URMXDSa9YqeJUQZxQPczV3K3Qpg1p13RnrNb1rtKKusdMI=----ATTACHMENT:----MjgwMjQyNjYyNDE4NDk5MiA3NTc2MDA4NzAyNjg3NTk1IDg2MjE1NzcyMTgwNzU3Nzg=