]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Restore the --edit workflow somewhat properly. (2)
authorepriestley <epriestley@phabricator.com>
Fri, 4 Mar 2011 22:51:39 +0000 (14:51 -0800)
committerepriestley <epriestley@phabricator.com>
Sat, 5 Mar 2011 00:37:41 +0000 (16:37 -0800)
Summary: summary999

Test Plan: test2

Reviewers:

CC:

Differential Revision: 219938

src/workflow/diff/ArcanistDiffWorkflow.php

index 6cb83b8779f205ac3d76f070fd65a67de2e59733..e91d18477b40ca7591f435c86314d83fb47bfd49 100644 (file)
@@ -337,6 +337,8 @@ EOTEXT
           'differential.getcommitmessage',
           array(
             'revision_id' => $message->getRevisionID(),
+            'edit' => true,
+            'fields' => array(),
           ));
         $remote_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
           $remote_corpus);
@@ -365,15 +367,64 @@ EOTEXT
           }
         }
 
+        $revision['fields'] = $remote_message->getFields();
+
         if ($should_edit) {
-          // TODO: lol. But we need differential.unparsecommitmessage or
-          // something.
-          throw new ArcanistUsageException(
-            '--edit is not supported yet. Edit revisions from the web '.
-            'UI.');
-        }
+          $updated_corpus = $conduit->callMethodSynchronous(
+            'differential.getcommitmessage',
+            array(
+              'revision_id' => $message->getRevisionID(),
+              'edit' => true,
+              'fields' => $message->getFields(),
+            ));
+          $new_text = id(new PhutilInteractiveEditor($updated_corpus))
+            ->setName('differential-edit-revision-info')
+            ->editInteractively();
+          $new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
+            $new_text);
+          $new_message->pullDataFromConduit($conduit);
+/*
+          TODO: restore these checks
 
-        $revision['fields'] = $remote_message->getFields();
+
+          try { // <<< this try goes right after the edit
+
+            if (!$new_message->getTitle()) {
+              throw new UsageException(
+                "You can not remove the Revision title.");
+            }
+            if (!$new_message->getTestPlan()) {
+              throw new UsageException(
+                "You can not remove the 'Test Plan'.");
+            }
+            if ($new_message->getRevisionID() != $revision->getID()) {
+              throw new UsageException(
+                "You changed or deleted the Differential revision ID! Why ".
+                "would you do that?!");
+            }
+
+          } catch (Exception $ex) {
+            $ii = 0;
+            do {
+              $name = $ii
+                ? 'differential-message-'.$ii.'.txt'
+                : 'differential-message.txt';
+              if (!file_exists($name)) {
+                break;
+              }
+              ++$ii;
+            } while(true);
+            require_module_lazy('resource/filesystem');
+            Filesystem::writeFile($name, $new_text);
+            echo "Exception! Message was saved to '{$name}'.\n";
+            throw $ex;
+          }
+*/
+
+
+
+          $revision['fields'] = $new_message->getFields();
+        }
 
         $update_message = $this->getUpdateMessage();