Page MenuHomePhabricator

D18742.id44990.diff
No OneTemporary

D18742.id44990.diff

diff --git a/src/differential/ArcanistDifferentialCommitMessage.php b/src/differential/ArcanistDifferentialCommitMessage.php
--- a/src/differential/ArcanistDifferentialCommitMessage.php
+++ b/src/differential/ArcanistDifferentialCommitMessage.php
@@ -8,6 +8,7 @@
private $rawCorpus;
private $revisionID;
private $fields = array();
+ private $xactions = null;
private $gitSVNBaseRevision;
private $gitSVNBasePath;
@@ -50,6 +51,9 @@
$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 @@
return md5($fields);
}
+ public function getTransactions() {
+ return $this->xactions;
+ }
+
/**
* Extract the revision ID from a commit message.
*
diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php
--- a/src/workflow/ArcanistDiffWorkflow.php
+++ b/src/workflow/ArcanistDiffWorkflow.php
@@ -21,6 +21,7 @@
private $diffPropertyFutures = array();
private $commitMessageFromRevision;
private $hitAutotargets;
+ private $revisionTransactions;
const STAGING_PUSHED = 'pushed';
const STAGING_USER_SKIP = 'user.skip';
@@ -525,16 +526,50 @@
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.
+
+ $xactions = $this->revisionTransactions;
+ if ($xactions) {
+ $xactions[] = array(
+ 'type' => 'update',
+ 'value' => $diff_info['phid'],
+ );
+
+ $result = $conduit->callMethodSynchronous(
+ 'differential.revision.edit',
+ array(
+ 'transactions' => $xactions,
+ ));
- $result = $conduit->callMethodSynchronous(
- 'differential.createrevision',
- $revision);
+ $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 @@
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 @@
$revision = array(
'fields' => $message->getFields(),
);
+ $xactions = $message->getTransactions();
if ($revision_id) {
@@ -694,6 +730,7 @@
}
$revision['fields'] = $new_message->getFields();
+ $xactions = $new_message->getTransactions();
$revision['id'] = $revision_id;
$this->revisionID = $revision_id;
@@ -716,6 +753,8 @@
}
}
+ $this->revisionTransactions = $xactions;
+
return $revision;
}

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 15, 3:09 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6711087
Default Alt Text
D18742.id44990.diff (3 KB)

Event Timeline