Path: blob/master/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php
12242 views
<?php12/**3* Execute and parse a low-level Mercurial paths query using `hg locate`.4*/5final class DiffusionLowLevelMercurialPathsQuery6extends DiffusionLowLevelQuery {78private $commit;9private $path;1011public function withCommit($commit) {12$this->commit = $commit;13return $this;14}1516public function withPath($path) {17$this->path = $path;18return $this;19}2021protected function executeQuery() {22$repository = $this->getRepository();23$path = $this->path;24$commit = $this->commit;2526$has_files = PhutilBinaryAnalyzer::getForBinary('hg')27->isMercurialFilesCommandAvailable();28if ($has_files) {29$hg_paths_command = 'files --print0 --rev %s -I %s';30} else {31$hg_paths_command = 'locate --print0 --rev %s -I %s';32}3334if ($path !== null) {35$match_against = trim($path, '/');36$prefix = trim('./'.$match_against, '/');37} else {38$prefix = '.';39}40list($entire_manifest) = $repository->execxLocalCommand(41$hg_paths_command,42hgsprintf('%s', $commit),43$prefix);44return explode("\0", $entire_manifest);45}4647}484950