mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 00:02:40 +01:00
Add a check for ambiguous merge strategies after the "history.immutable" behavioral change
Summary: Ref T13546. When users hit a situation where we would select "squash" but would previously select "merge", prevent them from continuing under ambiguous conditions. Test Plan: Ran "arc land" in Git with "history.immutable" true, false, and not configured. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21332
This commit is contained in:
parent
c5192bde34
commit
78e9cc9c01
2 changed files with 63 additions and 7 deletions
|
@ -229,6 +229,8 @@ final class ArcanistGitLandEngine
|
||||||
$api = $this->getRepositoryAPI();
|
$api = $this->getRepositoryAPI();
|
||||||
$log = $this->getLogEngine();
|
$log = $this->getLogEngine();
|
||||||
|
|
||||||
|
$this->confirmLegacyStrategyConfiguration();
|
||||||
|
|
||||||
$is_empty = ($into_commit === null);
|
$is_empty = ($into_commit === null);
|
||||||
|
|
||||||
if ($is_empty) {
|
if ($is_empty) {
|
||||||
|
@ -1429,4 +1431,50 @@ final class ArcanistGitLandEngine
|
||||||
return $refspecs;
|
return $refspecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function confirmLegacyStrategyConfiguration() {
|
||||||
|
// TODO: See T13547. Remove this check in the future. This prevents users
|
||||||
|
// from accidentally executing a "squash" workflow under a configuration
|
||||||
|
// which would previously have executed a "merge" workflow.
|
||||||
|
|
||||||
|
// We're fine if we have an explicit "--strategy".
|
||||||
|
if ($this->getStrategyArgument() !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're fine if we have an explicit "arc.land.strategy".
|
||||||
|
if ($this->getStrategyFromConfiguration() !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're fine if "history.immutable" is not set to "true".
|
||||||
|
$source_list = $this->getWorkflow()->getConfigurationSourceList();
|
||||||
|
$config_list = $source_list->getStorageValueList('history.immutable');
|
||||||
|
if (!$config_list) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$config_value = (bool)last($config_list)->getValue();
|
||||||
|
if (!$config_value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're in trouble: we would previously have selected "merge" and will
|
||||||
|
// now select "squash". Make sure the user knows what they're in for.
|
||||||
|
|
||||||
|
echo tsprintf(
|
||||||
|
"\n%!\n%W\n\n",
|
||||||
|
pht('MERGE STRATEGY IS AMBIGUOUS'),
|
||||||
|
pht(
|
||||||
|
'See <%s>. The default merge strategy under Git with '.
|
||||||
|
'"history.immutable" has changed from "merge" to "squash". Your '.
|
||||||
|
'configuration is ambiguous under this behavioral change. '.
|
||||||
|
'(Use "--strategy" or configure "arc.land.strategy" to bypass '.
|
||||||
|
'this check.)',
|
||||||
|
'https://secure.phabricator.com/T13547'));
|
||||||
|
|
||||||
|
throw new PhutilArgumentUsageException(
|
||||||
|
pht(
|
||||||
|
'Desired merge strategy is ambiguous, choose an explicit strategy.'));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,13 +269,17 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
return $this->localState;
|
return $this->localState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected function getOntoConfigurationKey() {
|
||||||
|
return 'arc.land.onto';
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function getOntoConfigurationKey() {
|
final protected function getOntoRemoteConfigurationKey() {
|
||||||
return 'arc.land.onto';
|
return 'arc.land.onto-remote';
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function getOntoRemoteFromConfiguration() {
|
final protected function getOntoRemoteFromConfiguration() {
|
||||||
|
@ -283,8 +287,13 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
return $this->getWorkflow()->getConfig($config_key);
|
return $this->getWorkflow()->getConfig($config_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function getOntoRemoteConfigurationKey() {
|
final protected function getStrategyConfigurationKey() {
|
||||||
return 'arc.land.onto-remote';
|
return 'arc.land.strategy';
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getStrategyFromConfiguration() {
|
||||||
|
$config_key = $this->getStrategyConfigurationKey();
|
||||||
|
return $this->getWorkflow()->getConfig($config_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function confirmRevisions(array $sets) {
|
final protected function confirmRevisions(array $sets) {
|
||||||
|
@ -1457,8 +1466,7 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
return $strategy;
|
return $strategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
$strategy_key = 'arc.land.strategy';
|
$strategy = $this->getStrategyFromConfiguration();
|
||||||
$strategy = $this->getWorkflow()->getConfig($strategy_key);
|
|
||||||
if ($strategy !== null) {
|
if ($strategy !== null) {
|
||||||
if (!isset($supported_strategies[$strategy])) {
|
if (!isset($supported_strategies[$strategy])) {
|
||||||
throw new PhutilArgumentUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
|
@ -1474,7 +1482,7 @@ abstract class ArcanistLandEngine extends Phobject {
|
||||||
pht(
|
pht(
|
||||||
'Merging with "%s" strategy, configured with "%s".',
|
'Merging with "%s" strategy, configured with "%s".',
|
||||||
$strategy,
|
$strategy,
|
||||||
$strategy_key));
|
$this->getStrategyConfigurationKey()));
|
||||||
|
|
||||||
return $strategy;
|
return $strategy;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue