From d3595328429037556b4b0e62aefe1f79e929fbf2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 9 Jan 2012 09:33:55 -0800 Subject: [PATCH] Add an "--update " flag to Arcanist Summary: See T614. This flag explicitly tells Arcanist to use the message for an existing revision, and attach the change to it directly. Next step is to have "arc diff" automatically choose "--create" or "--update" in the absence of "--create", "--update", "--only", "--preview" or a template commit message. Test Plan: Ran "arc diff --update " for various revisions. Got updates or errors as expected. Reviewers: btrahan, jungejason Reviewed By: btrahan CC: aran, btrahan, jungejason Maniphest Tasks: T614 Differential Revision: https://secure.phabricator.com/D1346 --- .../ArcanistDifferentialCommitMessage.php | 5 +- src/workflow/diff/ArcanistDiffWorkflow.php | 56 ++++++++++++++++++- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php b/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php index 8924f65c..f807221c 100644 --- a/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php +++ b/src/differential/commitmessage/ArcanistDifferentialCommitMessage.php @@ -1,7 +1,7 @@ callMethod( + $result = $conduit->callMethodSynchronous( 'differential.parsecommitmessage', array( 'corpus' => $this->rawCorpus, )); - $result = $result->resolve(); if (!empty($result['errors'])) { throw new ArcanistDifferentialCommitMessageParserException( $result['errors']); diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index 6a187457..449ba706 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -139,13 +139,19 @@ EOTEXT ), ), 'create' => array( - 'help' => "(EXPERIMENTAL) Create a new revision.", + 'help' => "Always create a new revision.", 'conflicts' => array( 'edit' => '--create can not be used with --edit.', 'only' => '--create can not be used with --only.', 'preview' => '--create can not be used with --preview.', + + 'update' => '--create can not be used with --update.', ), ), + 'update' => array( + 'param' => 'revision_id', + 'help' => "Always update a specific revision.", + ), 'nounit' => array( 'help' => "Do not run unit tests.", @@ -459,6 +465,10 @@ EOTEXT return false; } + if ($this->getArgument('update')) { + return false; + } + if ($this->isRawDiffSource()) { return true; } @@ -1061,6 +1071,7 @@ EOTEXT */ private function buildCommitMessage() { $is_create = $this->getArgument('create'); + $is_update = $this->getArgument('update'); $is_raw = $this->isRawDiffSource(); $message = null; @@ -1073,6 +1084,10 @@ EOTEXT } } + if ($is_update) { + return $this->getCommitMessageFromRevision($is_update); + } + if ($is_raw) { return null; } @@ -1144,6 +1159,45 @@ EOTEXT } + /** + * @task message + */ + private function getCommitMessageFromRevision($revision_id) { + $id = $this->normalizeRevisionID($revision_id); + + $revision = $this->getConduit()->callMethodSynchronous( + 'differential.query', + array( + 'ids' => array($id), + )); + $revision = head($revision); + + if (!$revision) { + throw new ArcanistUsageException( + "Revision '{$revision_id}' does not exist!"); + } + + if ($revision['authorPHID'] != $this->getUserPHID()) { + $rev_title = $revision['title']; + throw new ArcanistUsageException( + "You don't own revision D{$id} '{$rev_title}'. You can only update ". + "revisions you own."); + } + + $message = $this->getConduit()->callMethodSynchronous( + 'differential.getcommitmessage', + array( + 'revision_id' => $id, + 'edit' => false, + )); + + $obj = ArcanistDifferentialCommitMessage::newFromRawCorpus($message); + $obj->pullDataFromConduit($this->getConduit()); + + return $obj; + } + + /** * @task message */ -- 2.43.0