mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-25 06:50:55 +01:00
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
This commit is contained in:
parent
d40a30f10f
commit
0253bb9475
2 changed files with 28 additions and 11 deletions
|
@ -234,7 +234,7 @@ abstract class ArcanistBaseWorkflow {
|
||||||
'conduit.connect',
|
'conduit.connect',
|
||||||
array(
|
array(
|
||||||
'client' => 'arc',
|
'client' => 'arc',
|
||||||
'clientVersion' => 3,
|
'clientVersion' => 4,
|
||||||
'clientDescription' => php_uname('n').':'.$description,
|
'clientDescription' => php_uname('n').':'.$description,
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'certificate' => $certificate,
|
'certificate' => $certificate,
|
||||||
|
|
|
@ -300,8 +300,10 @@ EOTEXT
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'verbatim' => array(
|
'verbatim' => array(
|
||||||
'help' => 'Try to use the working copy commit message verbatim when '.
|
'help' => 'When creating a revision, try to use the working copy '.
|
||||||
'creating a revision, without prompting to edit it.',
|
'commit message verbatim, without prompting to edit it. '.
|
||||||
|
'When updating a revision, update some fields from the '.
|
||||||
|
'local commit message.',
|
||||||
'supports' => array(
|
'supports' => array(
|
||||||
'hg',
|
'hg',
|
||||||
'git',
|
'git',
|
||||||
|
@ -391,6 +393,18 @@ EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($message->getRevisionID()) {
|
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
|
// 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
|
// and then sending it right back to be parsed. This should be a
|
||||||
// single call.
|
// single call.
|
||||||
|
@ -398,22 +412,20 @@ EOTEXT
|
||||||
'differential.getcommitmessage',
|
'differential.getcommitmessage',
|
||||||
array(
|
array(
|
||||||
'revision_id' => $message->getRevisionID(),
|
'revision_id' => $message->getRevisionID(),
|
||||||
'edit' => true,
|
'edit' => 'edit',
|
||||||
'fields' => array(),
|
'fields' => $use_fields,
|
||||||
));
|
));
|
||||||
|
|
||||||
$should_edit = $this->getArgument('edit');
|
$should_edit = $this->getArgument('edit');
|
||||||
if ($should_edit) {
|
if ($should_edit) {
|
||||||
$new_text = id(new PhutilInteractiveEditor($remote_corpus))
|
$remote_corpus = id(new PhutilInteractiveEditor($remote_corpus))
|
||||||
->setName('differential-edit-revision-info')
|
->setName('differential-edit-revision-info')
|
||||||
->editInteractively();
|
->editInteractively();
|
||||||
$new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
|
|
||||||
$new_text);
|
|
||||||
} else {
|
|
||||||
$new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
|
|
||||||
$remote_corpus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
|
||||||
|
$remote_corpus);
|
||||||
|
|
||||||
$new_message->pullDataFromConduit($conduit);
|
$new_message->pullDataFromConduit($conduit);
|
||||||
$revision['fields'] = $new_message->getFields();
|
$revision['fields'] = $new_message->getFields();
|
||||||
|
|
||||||
|
@ -1224,11 +1236,16 @@ EOTEXT
|
||||||
$is_update = $this->getArgument('update');
|
$is_update = $this->getArgument('update');
|
||||||
$is_raw = $this->isRawDiffSource();
|
$is_raw = $this->isRawDiffSource();
|
||||||
$is_message = $this->getArgument('use-commit-message');
|
$is_message = $this->getArgument('use-commit-message');
|
||||||
|
$is_verbatim = $this->getArgument('verbatim');
|
||||||
|
|
||||||
if ($is_message) {
|
if ($is_message) {
|
||||||
return $this->getCommitMessageFromCommit($is_message);
|
return $this->getCommitMessageFromCommit($is_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($is_verbatim) {
|
||||||
|
return $this->getCommitMessageFromUser();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$is_raw && !$is_create && !$is_update) {
|
if (!$is_raw && !$is_create && !$is_update) {
|
||||||
$repository_api = $this->getRepositoryAPI();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
$revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
|
$revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
|
||||||
|
|
Loading…
Reference in a new issue