@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 44 lines 1.1 kB view raw
1<?php 2 3/** 4 * Execute and parse a low-level Mercurial paths query using `hg locate`. 5 */ 6final class DiffusionLowLevelMercurialPathsQuery 7 extends DiffusionLowLevelQuery { 8 9 private $commit; 10 private $path; 11 12 public function withCommit($commit) { 13 $this->commit = $commit; 14 return $this; 15 } 16 17 public function withPath($path) { 18 $this->path = $path; 19 return $this; 20 } 21 22 protected function executeQuery() { 23 $repository = $this->getRepository(); 24 $path = $this->path; 25 $commit = $this->commit; 26 27 $has_files = PhutilBinaryAnalyzer::getForBinary('hg') 28 ->isMercurialFilesCommandAvailable(); 29 if ($has_files) { 30 $hg_paths_command = 'files --print0 --rev %s -I %s'; 31 } else { 32 $hg_paths_command = 'locate --print0 --rev %s -I %s'; 33 } 34 35 $match_against = trim($path, '/'); 36 $prefix = trim('./'.$match_against, '/'); 37 list($entire_manifest) = $repository->execxLocalCommand( 38 $hg_paths_command, 39 hgsprintf('%s', $commit), 40 $prefix); 41 return explode("\0", $entire_manifest); 42 } 43 44}