]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Partially restore --edit to stop it from stomping all over everything.
authorepriestley <epriestley@phabricator.com>
Sun, 20 Feb 2011 06:07:12 +0000 (22:07 -0800)
committerepriestley <epriestley@phabricator.com>
Sun, 20 Feb 2011 06:14:53 +0000 (22:14 -0800)
Summary: We sync from local right now, which is fairly terrible. But
fixing this correctly is also not trivial and I don't have the right
primitives yet.

Test Plan:

Reviewers:

CC:

src/differential/commitmessage/ArcanistDifferentialCommitMessage.php
src/workflow/diff/ArcanistDiffWorkflow.php

index 3b0328eff69c5bc4eaa93869e61e42da196b3aa4..04a188cb24af475100c45eb16116cb49385d6c21 100644 (file)
@@ -80,6 +80,11 @@ class ArcanistDifferentialCommitMessage {
     return null;
   }
 
+  public function setFieldValue($key, $value) {
+    $this->fields[$key] = $value;
+    return $this;
+  }
+
   public function getFields() {
     return $this->fields;
   }
@@ -96,4 +101,11 @@ class ArcanistDifferentialCommitMessage {
     return $this->gitSVNUUID;
   }
 
+  public function getChecksum() {
+    $fields = array_filter($this->fields);
+    ksort($fields);
+    $fields = json_encode($fields);
+    return md5($fields);
+  }
+
 }
index 1b4bb42b5fd1b7fb2cb3aee26dc8358bc11e697b..f31d62798101a18ebe2aec44bba01c1a0bd4a585 100644 (file)
@@ -328,6 +328,50 @@ EOTEXT
       );
 
       if ($message->getRevisionID()) {
+        // TODO: This is silly -- we're getting a text corpus from the server
+        // and then sending it right back to be parsed. This should be a
+        // single call.
+        $remote_corpus = $conduit->callMethodSynchronous(
+          'differential.getcommitmessage',
+          array(
+            'revision_id' => $message->getRevisionID(),
+          ));
+        $remote_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
+          $remote_corpus);
+        $remote_message->pullDataFromConduit($conduit);
+
+        // TODO: We should throw here if you deleted the 'testPlan'.
+
+        $sync = array('title', 'summary', 'testPlan');
+        foreach ($sync as $field) {
+          $local = $message->getFieldValue($field);
+          $remote_message->setFieldValue($field, $local);
+        }
+
+        $should_edit = $this->getArgument('edit');
+        if (!$should_edit) {
+          $local_sum = $message->getChecksum();
+          $remote_sum = $remote_message->getChecksum();
+          if ($local_sum != $remote_sum) {
+            $prompt =
+              "You have made local changes to your commit message. Arcanist ".
+              "ignores most local changes. Instead, use the '--edit' flag to ".
+              "edit revision information. Edit revision information now?";
+            $should_edit = phutil_console_confirm(
+              $prompt,
+              $default_no = false);
+          }
+        }
+
+        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.');
+        }
+
+        $revision['fields'] = $remote_message->getFields();
 
         $update_message = $this->getUpdateMessage();