From 0253bb9475cca9c7557e797e26eaf5e1c688a436 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 7 May 2012 08:16:29 -0700 Subject: [PATCH] With `--verbatim`, update some fields automatically when updating revisions Summary: Essentially D2391, but with, uh, more comments? - I forgot that we already implemented shouldOverwriteWhenCommitMessageIsEdited(). This patch already behaves nearly correctly. - Requires changes in D2412. - Use `'edit' => 'edit'`, which does the same thing as `'edit' => true`, but is more correct after the "edit" / "create" split. - Under "--verbatim", always get the message "from the user", which means "from the working copy" because verbtatim disables the editor part. Test Plan: - Created and updated revisions with `arc diff`. - Created and updated revisions with `arc diff --verbatim`. - Updated revisions with `arc diff --edit`. Reviewers: jungejason, btrahan Reviewed By: jungejason CC: vrana, aran Differential Revision: https://secure.phabricator.com/D2411 --- src/workflow/base/ArcanistBaseWorkflow.php | 2 +- src/workflow/diff/ArcanistDiffWorkflow.php | 37 ++++++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/workflow/base/ArcanistBaseWorkflow.php b/src/workflow/base/ArcanistBaseWorkflow.php index 77061c72..fe5ca40b 100644 --- a/src/workflow/base/ArcanistBaseWorkflow.php +++ b/src/workflow/base/ArcanistBaseWorkflow.php @@ -234,7 +234,7 @@ abstract class ArcanistBaseWorkflow { 'conduit.connect', array( 'client' => 'arc', - 'clientVersion' => 3, + 'clientVersion' => 4, 'clientDescription' => php_uname('n').':'.$description, 'user' => $user, 'certificate' => $certificate, diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index 840c3008..33a13023 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -300,8 +300,10 @@ EOTEXT ), ), 'verbatim' => array( - 'help' => 'Try to use the working copy commit message verbatim when '. - 'creating a revision, without prompting to edit it.', + 'help' => 'When creating a revision, try to use the working copy '. + 'commit message verbatim, without prompting to edit it. '. + 'When updating a revision, update some fields from the '. + 'local commit message.', 'supports' => array( 'hg', 'git', @@ -391,6 +393,18 @@ EOTEXT ); if ($message->getRevisionID()) { + + // With '--verbatim', pass the (possibly modified) local fields. This + // allows the user to edit some fields (like "title" and "summary") + // locally without '--edit' and have changes automatically synchronized. + // Without '--verbatim', we do not update the revision to reflect local + // commit message changes. + if ($this->getArgument('verbatim')) { + $use_fields = $message->getFields(); + } else { + $use_fields = array(); + } + // 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. @@ -398,22 +412,20 @@ EOTEXT 'differential.getcommitmessage', array( 'revision_id' => $message->getRevisionID(), - 'edit' => true, - 'fields' => array(), + 'edit' => 'edit', + 'fields' => $use_fields, )); $should_edit = $this->getArgument('edit'); if ($should_edit) { - $new_text = id(new PhutilInteractiveEditor($remote_corpus)) + $remote_corpus = id(new PhutilInteractiveEditor($remote_corpus)) ->setName('differential-edit-revision-info') ->editInteractively(); - $new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus( - $new_text); - } else { - $new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus( - $remote_corpus); } + $new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus( + $remote_corpus); + $new_message->pullDataFromConduit($conduit); $revision['fields'] = $new_message->getFields(); @@ -1224,11 +1236,16 @@ EOTEXT $is_update = $this->getArgument('update'); $is_raw = $this->isRawDiffSource(); $is_message = $this->getArgument('use-commit-message'); + $is_verbatim = $this->getArgument('verbatim'); if ($is_message) { return $this->getCommitMessageFromCommit($is_message); } + if ($is_verbatim) { + return $this->getCommitMessageFromUser(); + } + if (!$is_raw && !$is_create && !$is_update) { $repository_api = $this->getRepositoryAPI(); $revisions = $repository_api->loadWorkingCopyDifferentialRevisions(