Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/protocol/DiffusionCommandEngine.php
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | abstract class DiffusionCommandEngine extends Phobject { | ||||
public function getSudoAsDaemon() { | public function getSudoAsDaemon() { | ||||
return $this->sudoAsDaemon; | return $this->sudoAsDaemon; | ||||
} | } | ||||
public function newFuture() { | public function newFuture() { | ||||
$argv = $this->newCommandArgv(); | $argv = $this->newCommandArgv(); | ||||
$env = $this->newCommandEnvironment(); | $env = $this->newCommandEnvironment(); | ||||
$is_passthru = $this->getPassthru(); | |||||
if ($this->getSudoAsDaemon()) { | if ($this->getSudoAsDaemon()) { | ||||
$command = call_user_func_array('csprintf', $argv); | $command = call_user_func_array('csprintf', $argv); | ||||
$command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | ||||
$argv = array('%C', $command); | $argv = array('%C', $command); | ||||
} | } | ||||
if ($this->getPassthru()) { | if ($is_passthru) { | ||||
$future = newv('PhutilExecPassthru', $argv); | $future = newv('PhutilExecPassthru', $argv); | ||||
} else { | } else { | ||||
$future = newv('ExecFuture', $argv); | $future = newv('ExecFuture', $argv); | ||||
} | } | ||||
$future->setEnv($env); | $future->setEnv($env); | ||||
// See T13108. By default, don't let any cluster command run indefinitely | // See T13108. By default, don't let any cluster command run indefinitely | ||||
// to try to avoid cases where `git fetch` hangs for some reason and we're | // to try to avoid cases where `git fetch` hangs for some reason and we're | ||||
// left sitting with a held lock forever. | // left sitting with a held lock forever. | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
if (!$is_passthru) { | |||||
$future->setTimeout($repository->getEffectiveCopyTimeLimit()); | $future->setTimeout($repository->getEffectiveCopyTimeLimit()); | ||||
} | |||||
return $future; | return $future; | ||||
} | } | ||||
private function newCommandArgv() { | private function newCommandArgv() { | ||||
$argv = $this->argv; | $argv = $this->argv; | ||||
$pattern = $argv[0]; | $pattern = $argv[0]; | ||||
$argv = array_slice($argv, 1); | $argv = array_slice($argv, 1); | ||||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |