]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Support "immutable_history" doctrine in arc
authorepriestley <git@epriestley.com>
Fri, 26 Aug 2011 00:53:59 +0000 (17:53 -0700)
committerepriestley <git@epriestley.com>
Thu, 15 Sep 2011 14:44:29 +0000 (07:44 -0700)
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

src/workflow/amend/ArcanistAmendWorkflow.php
src/workflow/base/ArcanistBaseWorkflow.php
src/workflow/diff/ArcanistDiffWorkflow.php

index e722e1375f7dc6d8204d1c47ac192befd41d2394..de5a33db28a92170aaee5bd4cf0647653b708f36 100644 (file)
@@ -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(
index 6a5a242bd1ef95cd646d1aaddf39ab60f68c6c0a..9bf75f5866a092ecd8d7bbffcd705470baf93016 100644 (file)
@@ -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);
+  }
+
 }
index 2a25f73a9e4af18e7952d612f40e21d9412ccd69..b10e0ade9298e6a17f0bb0f90312de7b56d2424e 100644 (file)
@@ -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();