]> khamidou — GitHub mirrors - arcanist.git/commitdiff
With `--verbatim`, update some fields automatically when updating revisions
authorepriestley <git@epriestley.com>
Mon, 7 May 2012 15:16:29 +0000 (08:16 -0700)
committerepriestley <git@epriestley.com>
Mon, 7 May 2012 15:16:29 +0000 (08:16 -0700)
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
src/workflow/diff/ArcanistDiffWorkflow.php

index 77061c72095396e50368eb290bcc85c66621f648..fe5ca40b60400e0b047fdceb05de073ca2d61b41 100644 (file)
@@ -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,
index 840c300817f447fddc13c7153ef005a80cca1c23..33a1302347e1ad4ee8fae2ecc15ccb714bf37ecd 100644 (file)
@@ -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(