Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistMercurialAPI.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Interfaces with the Mercurial working copies. | * Interfaces with the Mercurial working copies. | ||||
| */ | */ | ||||
| final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { | final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { | ||||
| private $branch; | private $branch; | ||||
| private $localCommitInfo; | private $localCommitInfo; | ||||
| private $rawDiffCache = array(); | private $rawDiffCache = array(); | ||||
| private $supportsRebase; | |||||
| private $supportsPhases; | |||||
| private $featureResults = array(); | private $featureResults = array(); | ||||
| private $featureFutures = array(); | private $featureFutures = array(); | ||||
| protected function buildLocalFuture(array $argv) { | protected function buildLocalFuture(array $argv) { | ||||
| $env = $this->getMercurialEnvironmentVariables(); | $env = $this->getMercurialEnvironmentVariables(); | ||||
| $argv[0] = 'hg '.$argv[0]; | $argv[0] = 'hg '.$argv[0]; | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | if ($this->getBaseCommitArgumentRules() || | ||||
| pht( | pht( | ||||
| "None of the rules in your 'base' configuration matched a valid ". | "None of the rules in your 'base' configuration matched a valid ". | ||||
| "commit. Adjust rules or specify which commit you want to use ". | "commit. Adjust rules or specify which commit you want to use ". | ||||
| "explicitly.")); | "explicitly.")); | ||||
| } | } | ||||
| return $base; | return $base; | ||||
| } | } | ||||
| // Mercurial 2.1 and up have phases which indicate if something is | |||||
| // published or not. To find which revs are outgoing, it's much | |||||
| // faster to check the phase instead of actually checking the server. | |||||
| if ($this->supportsPhases()) { | |||||
| list($err, $stdout) = $this->execManualLocal( | list($err, $stdout) = $this->execManualLocal( | ||||
| 'log --branch %s -r %s --style default', | 'log --branch %s -r %s --style default', | ||||
| $this->getBranchName(), | $this->getBranchName(), | ||||
| 'draft()'); | 'draft()'); | ||||
| } else { | |||||
| list($err, $stdout) = $this->execManualLocal( | |||||
| 'outgoing --branch %s --style default', | |||||
| $this->getBranchName()); | |||||
| } | |||||
| if (!$err) { | if (!$err) { | ||||
| $logs = ArcanistMercurialParser::parseMercurialLog($stdout); | $logs = ArcanistMercurialParser::parseMercurialLog($stdout); | ||||
| } else { | } else { | ||||
| // Mercurial (in some versions?) raises an error when there's nothing | // Mercurial (in some versions?) raises an error when there's nothing | ||||
| // outgoing. | // outgoing. | ||||
| $logs = array(); | $logs = array(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | public function supportsAmend() { | ||||
| list($err, $stdout) = $this->execManualLocal('help commit'); | list($err, $stdout) = $this->execManualLocal('help commit'); | ||||
| if ($err) { | if ($err) { | ||||
| return false; | return false; | ||||
| } else { | } else { | ||||
| return (strpos($stdout, 'amend') !== false); | return (strpos($stdout, 'amend') !== false); | ||||
| } | } | ||||
| } | } | ||||
| public function supportsRebase() { | |||||
| if ($this->supportsRebase === null) { | |||||
| list($err) = $this->execManualLocal('help rebase'); | |||||
| $this->supportsRebase = $err === 0; | |||||
| } | |||||
| return $this->supportsRebase; | |||||
| } | |||||
| public function supportsPhases() { | |||||
| if ($this->supportsPhases === null) { | |||||
| list($err) = $this->execManualLocal('help phase'); | |||||
| $this->supportsPhases = $err === 0; | |||||
| } | |||||
| return $this->supportsPhases; | |||||
| } | |||||
| public function supportsCommitRanges() { | public function supportsCommitRanges() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function supportsLocalCommits() { | public function supportsLocalCommits() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 688 Lines • Show Last 20 Lines | |||||