Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistRepositoryAPI.php
Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | public function execManualLocal($pattern /* , ... */) { | ||||
return $this->buildLocalFuture($args)->resolve(); | return $this->buildLocalFuture($args)->resolve(); | ||||
} | } | ||||
public function execFutureLocal($pattern /* , ... */) { | public function execFutureLocal($pattern /* , ... */) { | ||||
$args = func_get_args(); | $args = func_get_args(); | ||||
return $this->buildLocalFuture($args); | return $this->buildLocalFuture($args); | ||||
} | } | ||||
abstract protected function buildLocalFuture(array $argv); | /** | ||||
* Provide the name of the VCS binary, like `'git'`, `'hg'` or `'svn'`. | |||||
* | |||||
* @return string Name of the VCS binary. | |||||
*/ | |||||
abstract protected function getBinaryName(); | |||||
/** | |||||
* Provide environmental variables specific to this VCS. | |||||
* | |||||
* These variables will be passed to VCS subprocesses. For example, Mercurial | |||||
* needs to execute with HGPLAIN. | |||||
* | |||||
* @return map<string, string> Map of environmental variables to pass to | |||||
* VCS subprocesses. | |||||
*/ | |||||
protected function getExecutionEnvironment() { | |||||
return array(); | |||||
} | |||||
final protected function getCommonExecutionEnvironment() { | |||||
// The name of the "English, UTF-8" locale varies across systems. Try to | |||||
// identify the correct name on this system. | |||||
static $locale = null; | |||||
if ($locale === null) { | |||||
list($err, $locales) = exec_manual('locale -a'); | |||||
if ($err) { | |||||
// If we don't have `locale`, we're probably on Windows? This might | |||||
// not be the right thing to do? | |||||
$locale = 'en_US.UTF-8'; | |||||
} else { | |||||
$locales = phutil_split_lines($locales, $retain_endings = false); | |||||
$locales = array_fuse($locales); | |||||
$try = array( | |||||
'en_US.utf8', | |||||
'en_US.UTF-8', | |||||
); | |||||
foreach ($try as $try_locale) { | |||||
if (isset($locales[$try_locale])) { | |||||
$locale = $try_locale; | |||||
break; | |||||
} | |||||
} | |||||
if ($locale === null) { | |||||
throw new Exception( | |||||
pht( | |||||
'Unable to find a valid English UTF-8 locale on this system. '. | |||||
'One of these locales is required: %s. These locales were '. | |||||
'found: %s.', | |||||
implode(', ', $try), | |||||
implode(', ', $locales))); | |||||
} | |||||
} | |||||
} | |||||
return array( | |||||
'LANG' => $locale, | |||||
); | |||||
} | |||||
protected function buildLocalFuture(array $argv) { | |||||
list($command, $env) = $this->formatVCSCommand($argv); | |||||
return id(new ExecFuture('%C', $command)) | |||||
->setEnv($env) | |||||
->setCWD($this->getPath()); | |||||
} | |||||
public function execPassthru($pattern /* , ... */) { | |||||
$argv = func_get_args(); | |||||
list($command, $env) = $this->formatVCSCommand($argv); | |||||
// For passthru commands, we never parse the output and it's desirable | |||||
// to show it in the user's preferred language. | |||||
unset($env['LANG']); | |||||
$passthru = new PhutilExecPassthru('%C', $command); | |||||
$passthru->setEnv($env); | |||||
$passthru->setCWD($this->getPath()); | |||||
return $passthru->execute(); | |||||
} | |||||
private function formatVCSCommand(array $argv) { | |||||
$argv = call_user_func_array('csprintf', $argv); | |||||
$command = csprintf('%s %C', $this->getBinaryName(), $argv); | |||||
$env = $this->getExecutionEnvironment() + | |||||
$this->getCommonExecutionEnvironment(); | |||||
return array($command, $env); | |||||
} | |||||
public function canStashChanges() { | public function canStashChanges() { | ||||
return false; | return false; | ||||
} | } | ||||
public function stashChanges() { | public function stashChanges() { | ||||
throw new ArcanistCapabilityNotSupportedException($this); | throw new ArcanistCapabilityNotSupportedException($this); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |