From: vrana Date: Tue, 16 Oct 2012 18:51:15 +0000 (-0700) Subject: Don't pull message twice from Conduit in `arc diff` X-Git-Tag: conduit-6~83 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a850f1c6ef07dbd432f97a4b32312ca6fc43ec2d;p=arcanist.git 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 --- 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());