mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 00:42:40 +01:00
Add "arc diff --draft"
Summary: Experimental branch. Ref T2543. Depends on D18742. Add an "arc diff --draft" flag which holds revisions as drafts indefinitely. Test Plan: Ran "arc diff --draft" when creating; ran "arc diff --draft" to try to update a revision and got a failure. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18743
This commit is contained in:
parent
98cc64302e
commit
f1ba27ffed
2 changed files with 47 additions and 0 deletions
|
@ -38,6 +38,13 @@ final class ArcanistDifferentialCommitMessage extends Phobject {
|
|||
return $this->revisionID;
|
||||
}
|
||||
|
||||
public function getRevisionMonogram() {
|
||||
if ($this->revisionID) {
|
||||
return 'D'.$this->revisionID;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function pullDataFromConduit(
|
||||
ConduitClient $conduit,
|
||||
$partial = false) {
|
||||
|
|
|
@ -190,6 +190,16 @@ EOTEXT
|
|||
'param' => 'revision_id',
|
||||
'help' => pht('Always update a specific revision.'),
|
||||
),
|
||||
'draft' => array(
|
||||
'help' => pht(
|
||||
'Hold this revision as a draft instead of submitting it for '.
|
||||
'review.'),
|
||||
'conflicts' => array(
|
||||
'edit' => null,
|
||||
'only' => null,
|
||||
'update' => null,
|
||||
),
|
||||
),
|
||||
'nounit' => array(
|
||||
'help' => pht('Do not run unit tests.'),
|
||||
),
|
||||
|
@ -511,9 +521,21 @@ EOTEXT
|
|||
$this->openURIsInBrowser(array($diff_info['uri']));
|
||||
}
|
||||
} else {
|
||||
$is_draft = $this->getArgument('draft');
|
||||
$revision['diffid'] = $this->getDiffID();
|
||||
|
||||
if ($commit_message->getRevisionID()) {
|
||||
if ($is_draft) {
|
||||
// TODO: In at least some cases, we could raise this earlier in the
|
||||
// workflow to save users some time before the workflow aborts.
|
||||
throw new ArcanistUsageException(
|
||||
pht(
|
||||
'You are updating a revision ("%s") but have specified '.
|
||||
'the "--draft" flag. Only newly created revisions can be '.
|
||||
'held as drafts.',
|
||||
$commit_message->getRevisionMonogram()));
|
||||
}
|
||||
|
||||
$result = $conduit->callMethodSynchronous(
|
||||
'differential.updaterevision',
|
||||
$revision);
|
||||
|
@ -524,6 +546,9 @@ EOTEXT
|
|||
$this->writeScratchJSONFile($file, $messages);
|
||||
}
|
||||
|
||||
$result_uri = $result['uri'];
|
||||
$result_id = $result['revisionid'];
|
||||
|
||||
echo pht('Updated an existing Differential revision:')."\n";
|
||||
} else {
|
||||
// NOTE: We're either using "differential.revision.edit" (preferred)
|
||||
|
@ -537,6 +562,13 @@ EOTEXT
|
|||
'value' => $diff_info['phid'],
|
||||
);
|
||||
|
||||
if ($is_draft) {
|
||||
$xactions[] = array(
|
||||
'type' => 'draft',
|
||||
'value' => true,
|
||||
);
|
||||
}
|
||||
|
||||
$result = $conduit->callMethodSynchronous(
|
||||
'differential.revision.edit',
|
||||
array(
|
||||
|
@ -556,6 +588,14 @@ EOTEXT
|
|||
$result_uri = id(new PhutilURI($this->getConduitURI()))
|
||||
->setPath('/D'.$result_id);
|
||||
} else {
|
||||
if ($is_draft) {
|
||||
throw new ArcanistUsageException(
|
||||
pht(
|
||||
'You have specified "--draft", but the version of Phabricator '.
|
||||
'on the server is too old to support draft revisions. Omit '.
|
||||
'the flag or upgrade the server software.'));
|
||||
}
|
||||
|
||||
$revision = $this->dispatchWillCreateRevisionEvent($revision);
|
||||
|
||||
$result = $conduit->callMethodSynchronous(
|
||||
|
|
Loading…
Reference in a new issue