mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-09 16:32:39 +01:00
Add an "--update <revision>" 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 <n>" 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
This commit is contained in:
parent
9249ede952
commit
d359532842
2 changed files with 57 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -79,12 +79,11 @@ class ArcanistDifferentialCommitMessage {
|
|||
}
|
||||
|
||||
public function pullDataFromConduit(ConduitClient $conduit) {
|
||||
$result = $conduit->callMethod(
|
||||
$result = $conduit->callMethodSynchronous(
|
||||
'differential.parsecommitmessage',
|
||||
array(
|
||||
'corpus' => $this->rawCorpus,
|
||||
));
|
||||
$result = $result->resolve();
|
||||
if (!empty($result['errors'])) {
|
||||
throw new ArcanistDifferentialCommitMessageParserException(
|
||||
$result['errors']);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue