mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Improve final messages under "arc land --hold"
Summary: Ref T13546. Update some of the "arc land --hold" behavior to be more functional/consistent with the updated workflow. Test Plan: Ran "arc land --hold" under various conditions, got sensible forward/restore instructions. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21328
This commit is contained in:
parent
b62919f7e4
commit
4d61c00531
7 changed files with 164 additions and 59 deletions
|
@ -435,18 +435,10 @@ final class ArcanistGitLandEngine
|
||||||
pht('PUSHING'),
|
pht('PUSHING'),
|
||||||
pht('Pushing changes to "%s".', $this->getOntoRemote()));
|
pht('Pushing changes to "%s".', $this->getOntoRemote()));
|
||||||
|
|
||||||
$refspecs = array();
|
|
||||||
foreach ($this->getOntoRefs() as $onto_ref) {
|
|
||||||
$refspecs[] = sprintf(
|
|
||||||
'%s:%s',
|
|
||||||
$into_commit,
|
|
||||||
$onto_ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
$err = $api->execPassthru(
|
$err = $api->execPassthru(
|
||||||
'push -- %s %Ls',
|
'push -- %s %Ls',
|
||||||
$this->getOntoRemote(),
|
$this->getOntoRemote(),
|
||||||
$refspecs);
|
$this->newOntoRefArguments($into_commit));
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUsageException(
|
||||||
|
@ -738,57 +730,57 @@ final class ArcanistGitLandEngine
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function didHoldChanges(
|
protected function didHoldChanges($into_commit) {
|
||||||
ArcanistRepositoryLocalState $state) {
|
|
||||||
$log = $this->getLogEngine();
|
$log = $this->getLogEngine();
|
||||||
|
$local_state = $this->getLocalState();
|
||||||
// TODO: This probably needs updates.
|
|
||||||
|
|
||||||
// TODO: We should refuse "--hold" if we stash.
|
|
||||||
|
|
||||||
if ($this->getIsGitPerforce()) {
|
if ($this->getIsGitPerforce()) {
|
||||||
$this->writeInfo(
|
$message = pht(
|
||||||
pht('HOLD'),
|
'Holding changes locally, they have not been submitted.');
|
||||||
pht(
|
|
||||||
'Holding change locally, it has not been submitted.'));
|
|
||||||
|
|
||||||
$push_command = csprintf(
|
$push_command = csprintf(
|
||||||
'$ git p4 submit -M --commit %R --',
|
'git p4 submit -M --commit %s --',
|
||||||
$this->mergedRef);
|
$into_commit);
|
||||||
} else {
|
} else {
|
||||||
$log->writeStatus(
|
$message = pht(
|
||||||
pht('HOLD'),
|
'Holding changes locally, they have not been pushed.');
|
||||||
pht(
|
|
||||||
'Holding change locally, it has not been pushed.'));
|
|
||||||
|
|
||||||
$push_command = 'TODO: ...';
|
$push_command = csprintf(
|
||||||
// csprintf(
|
'git push -- %s %Ls',
|
||||||
// '$ git push -- %R %R:%R',
|
$this->getOntoRemote(),
|
||||||
// $this->getOntoRemote(),
|
$this->newOntoRefArguments($into_commit));
|
||||||
// $this->mergedRef,
|
|
||||||
// $this->getOnto());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$restore_command = 'TODO: ...';
|
echo tsprintf(
|
||||||
|
"\n%!\n%s\n\n",
|
||||||
|
pht('HOLD CHANGES'),
|
||||||
|
$message);
|
||||||
|
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n\n%>\n",
|
||||||
|
pht('To push changes manually, run this command:'),
|
||||||
|
$push_command);
|
||||||
|
|
||||||
|
$restore_commands = $local_state->getRestoreCommandsForDisplay();
|
||||||
|
if ($restore_commands) {
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n\n",
|
||||||
|
pht(
|
||||||
|
'To go back to how things were before you ran "arc land", run '.
|
||||||
|
'these %s command(s):',
|
||||||
|
phutil_count($restore_commands)));
|
||||||
|
|
||||||
|
foreach ($restore_commands as $restore_command) {
|
||||||
|
echo tsprintf('%>', $restore_command);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo tsprintf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
echo tsprintf(
|
echo tsprintf(
|
||||||
"\n%s\n\n".
|
|
||||||
"%s\n\n".
|
|
||||||
" **%s**\n\n".
|
|
||||||
"%s\n\n".
|
|
||||||
" **%s**\n\n".
|
|
||||||
"%s\n",
|
"%s\n",
|
||||||
pht(
|
pht(
|
||||||
'This local working copy now contains the merged changes in a '.
|
'Local branches have not been changed, and are still in the '.
|
||||||
'detached state.'),
|
|
||||||
pht('You can push the changes manually with this command:'),
|
|
||||||
$push_command,
|
|
||||||
pht(
|
|
||||||
'You can go back to how things were before you ran "arc land" with '.
|
|
||||||
'this command:'),
|
|
||||||
$restore_command,
|
|
||||||
pht(
|
|
||||||
'Local branches have not been changed, and are still in exactly the '.
|
|
||||||
'same state as before.'));
|
'same state as before.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1407,7 +1399,7 @@ final class ArcanistGitLandEngine
|
||||||
$log = $this->getLogEngine();
|
$log = $this->getLogEngine();
|
||||||
|
|
||||||
$branch = $api->getBranchName();
|
$branch = $api->getBranchName();
|
||||||
if ($branch === null) {
|
if ($branch !== null) {
|
||||||
$log->writeStatus(
|
$log->writeStatus(
|
||||||
pht('SOURCE'),
|
pht('SOURCE'),
|
||||||
pht(
|
pht(
|
||||||
|
@ -1425,7 +1417,20 @@ final class ArcanistGitLandEngine
|
||||||
'Landing the current HEAD, "%s".',
|
'Landing the current HEAD, "%s".',
|
||||||
$commit->getCommitHash()));
|
$commit->getCommitHash()));
|
||||||
|
|
||||||
return array($branch);
|
return array($commit->getCommitHash());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function newOntoRefArguments($into_commit) {
|
||||||
|
$refspecs = array();
|
||||||
|
|
||||||
|
foreach ($this->getOntoRefs() as $onto_ref) {
|
||||||
|
$refspecs[] = sprintf(
|
||||||
|
'%s:%s',
|
||||||
|
$this->getDisplayHash($into_commit),
|
||||||
|
$onto_ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $refspecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
private $intoEmpty;
|
private $intoEmpty;
|
||||||
private $intoLocal;
|
private $intoLocal;
|
||||||
|
|
||||||
|
private $localState;
|
||||||
|
|
||||||
final public function setViewer($viewer) {
|
final public function setViewer($viewer) {
|
||||||
$this->viewer = $viewer;
|
$this->viewer = $viewer;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -258,6 +260,15 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
return $this->intoArgument;
|
return $this->intoArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setLocalState(ArcanistRepositoryLocalState $local_state) {
|
||||||
|
$this->localState = $local_state;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getLocalState() {
|
||||||
|
return $this->localState;
|
||||||
|
}
|
||||||
|
|
||||||
final protected function getOntoFromConfiguration() {
|
final protected function getOntoFromConfiguration() {
|
||||||
$config_key = $this->getOntoConfigurationKey();
|
$config_key = $this->getOntoConfigurationKey();
|
||||||
return $this->getWorkflow()->getConfig($config_key);
|
return $this->getWorkflow()->getConfig($config_key);
|
||||||
|
@ -1232,6 +1243,8 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
->setWorkflow($workflow)
|
->setWorkflow($workflow)
|
||||||
->saveLocalState();
|
->saveLocalState();
|
||||||
|
|
||||||
|
$this->setLocalState($local_state);
|
||||||
|
|
||||||
$seen_into = array();
|
$seen_into = array();
|
||||||
try {
|
try {
|
||||||
$last_key = last_key($sets);
|
$last_key = last_key($sets);
|
||||||
|
@ -1309,19 +1322,18 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_hold) {
|
if ($is_hold) {
|
||||||
$this->didHoldChanges($local_state);
|
$this->didHoldChanges($into_commit);
|
||||||
$local_state->discardLocalState();
|
$local_state->discardLocalState();
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: Restore this.
|
||||||
|
// $this->getWorkflow()->askForRepositoryUpdate();
|
||||||
|
|
||||||
$this->reconcileLocalState($into_commit, $local_state);
|
$this->reconcileLocalState($into_commit, $local_state);
|
||||||
|
|
||||||
|
$log->writeSuccess(
|
||||||
|
pht('DONE'),
|
||||||
|
pht('Landed changes.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Restore this.
|
|
||||||
// $this->getWorkflow()->askForRepositoryUpdate();
|
|
||||||
|
|
||||||
// TODO: This is misleading under "--hold".
|
|
||||||
$log->writeSuccess(
|
|
||||||
pht('DONE'),
|
|
||||||
pht('Landed changes.'));
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$local_state->restoreLocalState();
|
$local_state->restoreLocalState();
|
||||||
throw $ex;
|
throw $ex;
|
||||||
|
@ -1413,6 +1425,8 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
$into_commit,
|
$into_commit,
|
||||||
ArcanistRepositoryLocalState $state);
|
ArcanistRepositoryLocalState $state);
|
||||||
|
|
||||||
|
abstract protected function didHoldChanges($into_commit);
|
||||||
|
|
||||||
private function selectMergeStrategy() {
|
private function selectMergeStrategy() {
|
||||||
$log = $this->getLogEngine();
|
$log = $this->getLogEngine();
|
||||||
|
|
||||||
|
|
|
@ -503,7 +503,7 @@ final class ArcanistMercurialLandEngine
|
||||||
|
|
||||||
$api->execxLocal(
|
$api->execxLocal(
|
||||||
'push --rev %s -- %s',
|
'push --rev %s -- %s',
|
||||||
$into_commit,
|
hgsprintf('%s', $into_commit),
|
||||||
$this->getOntoRemote());
|
$this->getOntoRemote());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,4 +600,52 @@ final class ArcanistMercurialLandEngine
|
||||||
$state->discardLocalState();
|
$state->discardLocalState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function didHoldChanges($into_commit) {
|
||||||
|
$log = $this->getLogEngine();
|
||||||
|
$local_state = $this->getLocalState();
|
||||||
|
|
||||||
|
$message = pht(
|
||||||
|
'Holding changes locally, they have not been pushed.');
|
||||||
|
|
||||||
|
$push_command = csprintf(
|
||||||
|
'$ hg push -- %s %Ls',
|
||||||
|
|
||||||
|
// TODO: When a parameter contains only "safe" characters, we could
|
||||||
|
// relax the behavior of hgsprintf().
|
||||||
|
|
||||||
|
hgsprintf('%s', $this->getDisplayHash($into_commit)),
|
||||||
|
$this->newOntoRefArguments($into_commit));
|
||||||
|
|
||||||
|
echo tsprintf(
|
||||||
|
"\n%!\n%s\n\n",
|
||||||
|
pht('HOLD CHANGES'),
|
||||||
|
$message);
|
||||||
|
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n\n **%s**\n\n",
|
||||||
|
pht('To push changes manually, run this command:'),
|
||||||
|
$push_command);
|
||||||
|
|
||||||
|
$restore_commands = $local_state->getRestoreCommandsForDisplay();
|
||||||
|
if ($restore_commands) {
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n\n",
|
||||||
|
pht(
|
||||||
|
'To go back to how things were before you ran "arc land", run '.
|
||||||
|
'these %s command(s):',
|
||||||
|
phutil_count($restore_commands)));
|
||||||
|
|
||||||
|
foreach ($restore_commands as $restore_command) {
|
||||||
|
echo tsprintf(" **%s**\n", $restore_command);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo tsprintf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n".
|
||||||
|
pht(
|
||||||
|
'Local branches and bookmarks have not been changed, and are still '.
|
||||||
|
'in the same state as before.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,29 @@ final class ArcanistGitLocalState
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newRestoreCommandsForDisplay() {
|
||||||
|
$ref = $this->localRef;
|
||||||
|
$commit = $this->localCommit;
|
||||||
|
|
||||||
|
$commands = array();
|
||||||
|
|
||||||
|
if ($ref !== null) {
|
||||||
|
$commands[] = csprintf(
|
||||||
|
'git checkout -B %s %s --',
|
||||||
|
$ref,
|
||||||
|
$this->getDisplayHash($commit));
|
||||||
|
} else {
|
||||||
|
$commands[] = csprintf(
|
||||||
|
'git checkout %s --',
|
||||||
|
$this->getDisplayHash($commit));
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: We run "submodule update" in the real restore workflow, but
|
||||||
|
// assume users can reasonably figure that out on their own.
|
||||||
|
|
||||||
|
return $commands;
|
||||||
|
}
|
||||||
|
|
||||||
protected function canStashChanges() {
|
protected function canStashChanges() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,11 @@ final class ArcanistMercurialLocalState
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newRestoreCommandsForDisplay() {
|
||||||
|
// TODO: Provide this.
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
protected function saveStash() {
|
protected function saveStash() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,10 @@ abstract class ArcanistRepositoryLocalState
|
||||||
$this->discardLocalState();
|
$this->discardLocalState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function getRestoreCommandsForDisplay() {
|
||||||
|
return $this->newRestoreCommandsForDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
protected function canStashChanges() {
|
protected function canStashChanges() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -208,6 +212,7 @@ abstract class ArcanistRepositoryLocalState
|
||||||
abstract protected function executeSaveLocalState();
|
abstract protected function executeSaveLocalState();
|
||||||
abstract protected function executeRestoreLocalState();
|
abstract protected function executeRestoreLocalState();
|
||||||
abstract protected function executeDiscardLocalState();
|
abstract protected function executeDiscardLocalState();
|
||||||
|
abstract protected function newRestoreCommandsForDisplay();
|
||||||
|
|
||||||
protected function getIgnoreHints() {
|
protected function getIgnoreHints() {
|
||||||
return array();
|
return array();
|
||||||
|
|
|
@ -53,6 +53,11 @@ function xsprintf_terminal($userdata, &$pattern, &$pos, &$value, &$length) {
|
||||||
$value = PhutilTerminalString::escapeStringValue($value, false);
|
$value = PhutilTerminalString::escapeStringValue($value, false);
|
||||||
$type = 's';
|
$type = 's';
|
||||||
break;
|
break;
|
||||||
|
case '>':
|
||||||
|
$value = tsprintf(" **$ %s**\n", $value);
|
||||||
|
$value = PhutilTerminalString::escapeStringValue($value, false);
|
||||||
|
$type = 's';
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
$type = 'd';
|
$type = 'd';
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue