From: epriestley Date: Sun, 20 Feb 2011 06:07:12 +0000 (-0800) Subject: Partially restore --edit to stop it from stomping all over everything. X-Git-Tag: conduit-4~394^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a4d30cc42bbca5fb300ff6ccb8b3580a3fbcc937;p=arcanist.git Partially restore --edit to stop it from stomping all over everything. 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: --- diff --git a/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php b/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php index 3b0328ef..04a188cb 100644 --- a/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php +++ b/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php @@ -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); + } + } diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index 1b4bb42b..f31d6279 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -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();