]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't pull message twice from Conduit in `arc diff`
authorvrana <jakubv@fb.com>
Tue, 16 Oct 2012 18:51:15 +0000 (11:51 -0700)
committervrana <jakubv@fb.com>
Tue, 16 Oct 2012 19:53:59 +0000 (12:53 -0700)
Summary:
We currently pull message from Conduit twice in `arc diff` update.
Once in `buildCommitMessage()` and once in `buildRevisionFromCommitMessage()`.
Remeber that we already pulled it (and so it is authoritative) to save this call.

Even faster solution would be to not pull and update the message at all in common (non-`--edit`, non-`--verbatim` and such) update workflows but it's more involved.

Test Plan:
  $ arc diff --trace

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3716

src/workflow/ArcanistDiffWorkflow.php

index d85cae52ae041eae2916740aed55aeacd071c9e0..cdec2cb6feb56f7631102f4e665345df91061621 100644 (file)
@@ -39,6 +39,7 @@ final class ArcanistDiffWorkflow extends ArcanistBaseWorkflow {
   private $postponedLinters;
   private $haveUncommittedChanges = false;
   private $diffPropertyFutures = array();
+  private $commitMessageFromRevision;
 
   public function getCommandSynopses() {
     return phutil_console_format(<<<EOTEXT
@@ -613,7 +614,9 @@ EOTEXT
     }
   }
 
-  private function buildRevisionFromCommitMessage($message) {
+  private function buildRevisionFromCommitMessage(
+    ArcanistDifferentialCommitMessage $message) {
+
     $conduit = $this->getConduit();
 
     $revision_id = $message->getRevisionID();
@@ -639,27 +642,38 @@ EOTEXT
       $remote_corpus = idx($edit_messages, $revision_id);
 
       if (!$should_edit || !$remote_corpus || $use_fields) {
-        $remote_corpus = $conduit->callMethodSynchronous(
-          'differential.getcommitmessage',
-          array(
-            'revision_id' => $revision_id,
-            'edit'        => 'edit',
-            'fields'      => $use_fields,
-          ));
+        if ($this->commitMessageFromRevision) {
+          $remote_corpus = $this->commitMessageFromRevision;
+        } else {
+          $remote_corpus = $conduit->callMethodSynchronous(
+            'differential.getcommitmessage',
+            array(
+              'revision_id' => $revision_id,
+              'edit'        => 'edit',
+              'fields'      => $use_fields,
+            ));
+        }
       }
 
       if ($should_edit) {
-        $remote_corpus = $this->newInteractiveEditor($remote_corpus)
+        $edited = $this->newInteractiveEditor($remote_corpus)
           ->setName('differential-edit-revision-info')
           ->editInteractively();
-        $edit_messages[$revision_id] = $remote_corpus;
-        $this->writeScratchJSONFile('edit-messages.json', $edit_messages);
+        if ($edited != $remote_corpus) {
+          $remote_corpus = $edited;
+          $edit_messages[$revision_id] = $remote_corpus;
+          $this->writeScratchJSONFile('edit-messages.json', $edit_messages);
+        }
       }
 
-      $new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
-        $remote_corpus);
+      if ($this->commitMessageFromRevision == $remote_corpus) {
+        $new_message = $message;
+      } else {
+        $new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
+          $remote_corpus);
+        $new_message->pullDataFromConduit($conduit);
+      }
 
-      $new_message->pullDataFromConduit($conduit);
       $revision['fields'] = $new_message->getFields();
 
       $revision['id'] = $revision_id;
@@ -1702,6 +1716,7 @@ EOTEXT
         'revision_id' => $id,
         'edit'        => false,
       ));
+    $this->commitMessageFromRevision = $message;
 
     $obj = ArcanistDifferentialCommitMessage::newFromRawCorpus($message);
     $obj->pullDataFromConduit($this->getConduit());