From a850f1c6ef07dbd432f97a4b32312ca6fc43ec2d Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 16 Oct 2012 11:51:15 -0700 Subject: [PATCH] Don't pull message twice from Conduit in `arc diff` 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 | 43 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index d85cae52..cdec2cb6 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -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(<<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()); -- 2.43.0