mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 08:12:40 +01:00
In "arc land" in Mercurial, show a tidier "ls-remote" command
Summary: Ref T9948. Ref T13546. We must passthru "hg ls-remote" because it might prompt the user for credentials. Since "ls-remote" is implemented as an exension and we can't rely on using stdout beacuse of passthru, the actual command we execute is: ``` $ hg --config extensions.arc-hg=<huge long path to extension> arc-ls-remote --output <huge long path to temporary file> -- remote ``` This is meaningless and distracting; show the intent of the command we're executing instead. Users can see the raw command in "--trace" if they're actually debugging behavior. Test Plan: Ran "arc land" in a Mercurial repository, got a tidier command output. Maniphest Tasks: T13546, T9948 Differential Revision: https://secure.phabricator.com/D21344
This commit is contained in:
parent
b1f807f7ca
commit
3cad824e38
3 changed files with 37 additions and 7 deletions
|
@ -1547,7 +1547,7 @@ abstract class ArcanistLandEngine
|
||||||
return $sets;
|
return $sets;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function newPassthru($pattern /* , ... */) {
|
final protected function newPassthruCommand($pattern /* , ... */) {
|
||||||
$workflow = $this->getWorkflow();
|
$workflow = $this->getWorkflow();
|
||||||
$argv = func_get_args();
|
$argv = func_get_args();
|
||||||
|
|
||||||
|
@ -1560,6 +1560,16 @@ abstract class ArcanistLandEngine
|
||||||
$command = $workflow->newCommand($passthru)
|
$command = $workflow->newCommand($passthru)
|
||||||
->setResolveOnError(true);
|
->setResolveOnError(true);
|
||||||
|
|
||||||
|
return $command;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function newPassthru($pattern /* , ... */) {
|
||||||
|
$argv = func_get_args();
|
||||||
|
|
||||||
|
$command = call_user_func_array(
|
||||||
|
array($this, 'newPassthruCommand'),
|
||||||
|
$argv);
|
||||||
|
|
||||||
return $command->execute();
|
return $command->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -455,18 +455,20 @@ final class ArcanistMercurialLandEngine
|
||||||
// NOTE: We're using passthru on this because it's a remote command and
|
// NOTE: We're using passthru on this because it's a remote command and
|
||||||
// may prompt the user for credentials.
|
// may prompt the user for credentials.
|
||||||
|
|
||||||
// TODO: This is fairly silly/confusing to show to users in the common
|
|
||||||
// case where it does not require credentials, particularly because the
|
|
||||||
// actual command line is full of nonsense.
|
|
||||||
|
|
||||||
$tmpfile = new TempFile();
|
$tmpfile = new TempFile();
|
||||||
Filesystem::remove($tmpfile);
|
Filesystem::remove($tmpfile);
|
||||||
|
|
||||||
$err = $this->newPassthru(
|
$command = $this->newPassthruCommand(
|
||||||
'%Ls arc-ls-remote --output %s -- %s',
|
'%Ls arc-ls-remote --output %s -- %s',
|
||||||
$api->getMercurialExtensionArguments(),
|
$api->getMercurialExtensionArguments(),
|
||||||
phutil_string_cast($tmpfile),
|
phutil_string_cast($tmpfile),
|
||||||
$target->getRemote());
|
$target->getRemote());
|
||||||
|
|
||||||
|
$command->setDisplayCommand(
|
||||||
|
'hg ls-remote -- %s',
|
||||||
|
$target->getRemote());
|
||||||
|
|
||||||
|
$err = $command->execute();
|
||||||
if ($err) {
|
if ($err) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
pht(
|
pht(
|
||||||
|
|
|
@ -6,6 +6,7 @@ final class ArcanistCommand
|
||||||
private $logEngine;
|
private $logEngine;
|
||||||
private $executableFuture;
|
private $executableFuture;
|
||||||
private $resolveOnError = false;
|
private $resolveOnError = false;
|
||||||
|
private $displayCommand;
|
||||||
|
|
||||||
public function setExecutableFuture(PhutilExecutableFuture $future) {
|
public function setExecutableFuture(PhutilExecutableFuture $future) {
|
||||||
$this->executableFuture = $future;
|
$this->executableFuture = $future;
|
||||||
|
@ -34,10 +35,27 @@ final class ArcanistCommand
|
||||||
return $this->resolveOnError;
|
return $this->resolveOnError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDisplayCommand($pattern /* , ... */) {
|
||||||
|
$argv = func_get_args();
|
||||||
|
$command = call_user_func_array('csprintf', $argv);
|
||||||
|
$this->displayCommand = $command;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDisplayCommand() {
|
||||||
|
return $this->displayCommand;
|
||||||
|
}
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
$log = $this->getLogEngine();
|
$log = $this->getLogEngine();
|
||||||
$future = $this->getExecutableFuture();
|
$future = $this->getExecutableFuture();
|
||||||
|
|
||||||
|
$display_command = $this->getDisplayCommand();
|
||||||
|
if ($display_command !== null) {
|
||||||
|
$command = $display_command;
|
||||||
|
} else {
|
||||||
$command = $future->getCommand();
|
$command = $future->getCommand();
|
||||||
|
}
|
||||||
|
|
||||||
$log->writeNewline();
|
$log->writeNewline();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue