Summary: When a project uses a conservative history mutability doctrine, never
try to amend history.
Test Plan: Ran "arc amend" in an "immutable_history" working copy.
Reviewers: fratrik, Makinde, aran, jungejason, tuomaspelkonen
Reviewed By: Makinde
CC: aran, Makinde, epriestley
Differential Revision: 862
}
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(
file_put_contents('php://stderr', $msg);
}
+ protected function isHistoryImmutable() {
+ $working_copy = $this->getWorkingCopy();
+ return ($working_copy->getConfig('immutable_history') === true);
+ }
+
}
}
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;
}
}
$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();