1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-29 17:00:58 +01:00

If possible, use "differential.revision.edit" in "arc diff"

Summary:
Depends on D18741. Switches to "differential.revision.edit" if we get a transaction list back from parsing (added by D18740).

This will allow us to use new transactions, notably "Hold as Draft" for "--draft".

Test Plan: Ran `arc diff`, got a revision via `differential.revision.edit`.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18742
This commit is contained in:
epriestley 2017-10-27 09:27:41 -07:00
parent 52992b9550
commit 98cc64302e
2 changed files with 53 additions and 6 deletions

View file

@ -8,6 +8,7 @@ final class ArcanistDifferentialCommitMessage extends Phobject {
private $rawCorpus;
private $revisionID;
private $fields = array();
private $xactions = null;
private $gitSVNBaseRevision;
private $gitSVNBasePath;
@ -50,6 +51,9 @@ final class ArcanistDifferentialCommitMessage extends Phobject {
$this->fields = $result['fields'];
// NOTE: This does not exist prior to late October 2017.
$this->xactions = idx($result, 'transactions');
if (!empty($result['errors'])) {
throw new ArcanistDifferentialCommitMessageParserException(
$result['errors']);
@ -93,6 +97,10 @@ final class ArcanistDifferentialCommitMessage extends Phobject {
return md5($fields);
}
public function getTransactions() {
return $this->xactions;
}
/**
* Extract the revision ID from a commit message.
*

View file

@ -21,6 +21,7 @@ final class ArcanistDiffWorkflow extends ArcanistWorkflow {
private $diffPropertyFutures = array();
private $commitMessageFromRevision;
private $hitAutotargets;
private $revisionTransactions;
const STAGING_PUSHED = 'pushed';
const STAGING_USER_SKIP = 'user.skip';
@ -525,16 +526,50 @@ EOTEXT
echo pht('Updated an existing Differential revision:')."\n";
} else {
$revision = $this->dispatchWillCreateRevisionEvent($revision);
// NOTE: We're either using "differential.revision.edit" (preferred)
// if we can, or falling back to "differential.createrevision"
// (the older way) if not.
$result = $conduit->callMethodSynchronous(
'differential.createrevision',
$revision);
$xactions = $this->revisionTransactions;
if ($xactions) {
$xactions[] = array(
'type' => 'update',
'value' => $diff_info['phid'],
);
$result = $conduit->callMethodSynchronous(
'differential.revision.edit',
array(
'transactions' => $xactions,
));
$result_id = idxv($result, array('object', 'id'));
if (!$result_id) {
throw new Exception(
pht(
'Expected a revision ID to be returned by '.
'"differential.revision.edit".'));
}
// TODO: This is hacky, but we don't currently receive a URI back
// from "differential.revision.edit".
$result_uri = id(new PhutilURI($this->getConduitURI()))
->setPath('/D'.$result_id);
} else {
$revision = $this->dispatchWillCreateRevisionEvent($revision);
$result = $conduit->callMethodSynchronous(
'differential.createrevision',
$revision);
$result_uri = $result['uri'];
$result_id = $result['revisionid'];
}
$revised_message = $conduit->callMethodSynchronous(
'differential.getcommitmessage',
array(
'revision_id' => $result['revisionid'],
'revision_id' => $result_id,
));
if ($this->shouldAmend()) {
@ -552,7 +587,7 @@ EOTEXT
echo pht('Created a new Differential revision:')."\n";
}
$uri = $result['uri'];
$uri = $result_uri;
echo phutil_console_format(
" **%s** __%s__\n\n",
pht('Revision URI:'),
@ -640,6 +675,7 @@ EOTEXT
$revision = array(
'fields' => $message->getFields(),
);
$xactions = $message->getTransactions();
if ($revision_id) {
@ -694,6 +730,7 @@ EOTEXT
}
$revision['fields'] = $new_message->getFields();
$xactions = $new_message->getTransactions();
$revision['id'] = $revision_id;
$this->revisionID = $revision_id;
@ -716,6 +753,8 @@ EOTEXT
}
}
$this->revisionTransactions = $xactions;
return $revision;
}