diff --git a/src/workflow/amend/ArcanistAmendWorkflow.php b/src/workflow/amend/ArcanistAmendWorkflow.php index e722e137..de5a33db 100644 --- a/src/workflow/amend/ArcanistAmendWorkflow.php +++ b/src/workflow/amend/ArcanistAmendWorkflow.php @@ -65,6 +65,14 @@ EOTEXT } public function run() { + if ($this->isHistoryImmutable()) { + throw new ArcanistUsageException( + "This project is marked as adhering to a conservative history ". + "mutability doctrine (having an immutable local history), which ". + "precludes amending commit messages. You can use 'arc merge' to ". + "merge feature branches instead."); + } + $repository_api = $this->getRepositoryAPI(); if (!($repository_api instanceof ArcanistGitAPI)) { throw new ArcanistUsageException( diff --git a/src/workflow/base/ArcanistBaseWorkflow.php b/src/workflow/base/ArcanistBaseWorkflow.php index 6a5a242b..9bf75f58 100644 --- a/src/workflow/base/ArcanistBaseWorkflow.php +++ b/src/workflow/base/ArcanistBaseWorkflow.php @@ -913,4 +913,9 @@ class ArcanistBaseWorkflow { file_put_contents('php://stderr', $msg); } + protected function isHistoryImmutable() { + $working_copy = $this->getWorkingCopy(); + return ($working_copy->getConfig('immutable_history') === true); + } + } diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index 2a25f73a..b10e0ade 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -549,8 +549,10 @@ EOTEXT } if ($repository_api instanceof ArcanistMercurialAPI) { - // TODO: This is unlikely to be correct since it excludes using local - // branching in Mercurial. + return true; + } + + if ($this->isHistoryImmutable()) { return true; } @@ -1110,7 +1112,10 @@ EOTEXT } $lint_workflow = $this->buildChildWorkflow('lint', $argv); - $lint_workflow->setShouldAmendChanges(true); + if (!$this->isHistoryImmutable()) { + // TODO: We should offer to create a checkpoint commit. + $lint_workflow->setShouldAmendChanges(true); + } $lint_result = $lint_workflow->run();