mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Add "Author" and "Parent Revision" hardpoints to RevisionRefs
Summary: Ref T13546. These are used by a future "arc land" workflow to support the "Land changes you don't own?" and "Land changes with open dependencies?" prompts. Test Plan: Ran a future "arc land" flow, hit both prompts. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21311
This commit is contained in:
parent
8b973bf439
commit
c1a4bee4a1
4 changed files with 160 additions and 0 deletions
|
@ -400,7 +400,9 @@ phutil_register_library_map(array(
|
||||||
'ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase.php',
|
'ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase.php',
|
||||||
'ArcanistReusedIteratorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistReusedIteratorXHPASTLinterRule.php',
|
'ArcanistReusedIteratorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistReusedIteratorXHPASTLinterRule.php',
|
||||||
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorXHPASTLinterRuleTestCase.php',
|
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorXHPASTLinterRuleTestCase.php',
|
||||||
|
'ArcanistRevisionAuthorHardpointQuery' => 'ref/revision/ArcanistRevisionAuthorHardpointQuery.php',
|
||||||
'ArcanistRevisionCommitMessageHardpointQuery' => 'ref/revision/ArcanistRevisionCommitMessageHardpointQuery.php',
|
'ArcanistRevisionCommitMessageHardpointQuery' => 'ref/revision/ArcanistRevisionCommitMessageHardpointQuery.php',
|
||||||
|
'ArcanistRevisionParentRevisionRefsHardpointQuery' => 'ref/revision/ArcanistRevisionParentRevisionRefsHardpointQuery.php',
|
||||||
'ArcanistRevisionRef' => 'ref/revision/ArcanistRevisionRef.php',
|
'ArcanistRevisionRef' => 'ref/revision/ArcanistRevisionRef.php',
|
||||||
'ArcanistRevisionRefSource' => 'ref/ArcanistRevisionRefSource.php',
|
'ArcanistRevisionRefSource' => 'ref/ArcanistRevisionRefSource.php',
|
||||||
'ArcanistRevisionSymbolRef' => 'ref/revision/ArcanistRevisionSymbolRef.php',
|
'ArcanistRevisionSymbolRef' => 'ref/revision/ArcanistRevisionSymbolRef.php',
|
||||||
|
@ -1390,7 +1392,9 @@ phutil_register_library_map(array(
|
||||||
'ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
'ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||||
'ArcanistReusedIteratorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistReusedIteratorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||||
|
'ArcanistRevisionAuthorHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
|
||||||
'ArcanistRevisionCommitMessageHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
|
'ArcanistRevisionCommitMessageHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
|
||||||
|
'ArcanistRevisionParentRevisionRefsHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
|
||||||
'ArcanistRevisionRef' => array(
|
'ArcanistRevisionRef' => array(
|
||||||
'ArcanistRef',
|
'ArcanistRef',
|
||||||
'ArcanistDisplayRefInterface',
|
'ArcanistDisplayRefInterface',
|
||||||
|
|
35
src/ref/revision/ArcanistRevisionAuthorHardpointQuery.php
Normal file
35
src/ref/revision/ArcanistRevisionAuthorHardpointQuery.php
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ArcanistRevisionAuthorHardpointQuery
|
||||||
|
extends ArcanistRuntimeHardpointQuery {
|
||||||
|
|
||||||
|
public function getHardpoints() {
|
||||||
|
return array(
|
||||||
|
ArcanistRevisionRef::HARDPOINT_AUTHORREF,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function canLoadRef(ArcanistRef $ref) {
|
||||||
|
return ($ref instanceof ArcanistRevisionRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadHardpoint(array $refs, $hardpoint) {
|
||||||
|
|
||||||
|
$symbols = array();
|
||||||
|
foreach ($refs as $key => $ref) {
|
||||||
|
$symbols[$key] = id(new ArcanistUserSymbolRef())
|
||||||
|
->setSymbol($ref->getAuthorPHID());
|
||||||
|
}
|
||||||
|
|
||||||
|
yield $this->yieldRequests(
|
||||||
|
$symbols,
|
||||||
|
array(
|
||||||
|
ArcanistSymbolRef::HARDPOINT_OBJECT,
|
||||||
|
));
|
||||||
|
|
||||||
|
$results = mpull($symbols, 'getObject');
|
||||||
|
|
||||||
|
yield $this->yieldMap($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ArcanistRevisionParentRevisionRefsHardpointQuery
|
||||||
|
extends ArcanistRuntimeHardpointQuery {
|
||||||
|
|
||||||
|
public function getHardpoints() {
|
||||||
|
return array(
|
||||||
|
ArcanistRevisionRef::HARDPOINT_PARENTREVISIONREFS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function canLoadRef(ArcanistRef $ref) {
|
||||||
|
return ($ref instanceof ArcanistRevisionRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadHardpoint(array $refs, $hardpoint) {
|
||||||
|
$parameters = array(
|
||||||
|
'sourcePHIDs' => mpull($refs, 'getPHID'),
|
||||||
|
'types' => array(
|
||||||
|
'revision.parent',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
while (true) {
|
||||||
|
$results = (yield $this->yieldConduit(
|
||||||
|
'edge.search',
|
||||||
|
$parameters));
|
||||||
|
|
||||||
|
foreach ($results['data'] as $item) {
|
||||||
|
$data[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($results['cursor']['after'] === null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parameters['after'] = $results['cursor']['after'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$data) {
|
||||||
|
yield $this->yieldValue($refs, array());
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = array();
|
||||||
|
$symbols = array();
|
||||||
|
foreach ($data as $edge) {
|
||||||
|
$src = $edge['sourcePHID'];
|
||||||
|
$dst = $edge['destinationPHID'];
|
||||||
|
|
||||||
|
$map[$src][$dst] = $dst;
|
||||||
|
|
||||||
|
$symbols[$dst] = id(new ArcanistRevisionSymbolRef())
|
||||||
|
->setSymbol($dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield $this->yieldRequests(
|
||||||
|
$symbols,
|
||||||
|
array(
|
||||||
|
ArcanistSymbolRef::HARDPOINT_OBJECT,
|
||||||
|
));
|
||||||
|
|
||||||
|
$objects = array();
|
||||||
|
foreach ($symbols as $key => $symbol) {
|
||||||
|
$object = $symbol->getObject();
|
||||||
|
if ($object) {
|
||||||
|
$objects[$key] = $object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = array_fill_keys(array_keys($refs), array());
|
||||||
|
foreach ($refs as $ref_key => $ref) {
|
||||||
|
$revision_phid = $ref->getPHID();
|
||||||
|
$parent_phids = idx($map, $revision_phid, array());
|
||||||
|
$parent_refs = array_select_keys($objects, $parent_phids);
|
||||||
|
$results[$ref_key] = $parent_refs;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield $this->yieldMap($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,8 @@ final class ArcanistRevisionRef
|
||||||
ArcanistDisplayRefInterface {
|
ArcanistDisplayRefInterface {
|
||||||
|
|
||||||
const HARDPOINT_COMMITMESSAGE = 'ref.revision.commitmessage';
|
const HARDPOINT_COMMITMESSAGE = 'ref.revision.commitmessage';
|
||||||
|
const HARDPOINT_AUTHORREF = 'ref.revision.authorRef';
|
||||||
|
const HARDPOINT_PARENTREVISIONREFS = 'ref.revision.parentRevisionRefs';
|
||||||
|
|
||||||
private $parameters;
|
private $parameters;
|
||||||
private $sources = array();
|
private $sources = array();
|
||||||
|
@ -15,8 +17,13 @@ final class ArcanistRevisionRef
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newHardpoints() {
|
protected function newHardpoints() {
|
||||||
|
$object_list = new ArcanistObjectListHardpoint();
|
||||||
return array(
|
return array(
|
||||||
$this->newHardpoint(self::HARDPOINT_COMMITMESSAGE),
|
$this->newHardpoint(self::HARDPOINT_COMMITMESSAGE),
|
||||||
|
$this->newHardpoint(self::HARDPOINT_AUTHORREF),
|
||||||
|
$this->newTemplateHardpoint(
|
||||||
|
self::HARDPOINT_PARENTREVISIONREFS,
|
||||||
|
$object_list),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +70,30 @@ final class ArcanistRevisionRef
|
||||||
return idxv($this->parameters, array('fields', 'status', 'name'));
|
return idxv($this->parameters, array('fields', 'status', 'name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isStatusChangesPlanned() {
|
||||||
|
$status = $this->getStatus();
|
||||||
|
return ($status === 'changes-planned');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isStatusAbandoned() {
|
||||||
|
$status = $this->getStatus();
|
||||||
|
return ($status === 'abandoned');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isStatusClosed() {
|
||||||
|
$status = $this->getStatus();
|
||||||
|
return ($status === 'closed');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isStatusAccepted() {
|
||||||
|
$status = $this->getStatus();
|
||||||
|
return ($status === 'accepted');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatus() {
|
||||||
|
return idxv($this->parameters, array('fields', 'status', 'value'));
|
||||||
|
}
|
||||||
|
|
||||||
public function isClosed() {
|
public function isClosed() {
|
||||||
return idxv($this->parameters, array('fields', 'status', 'closed'));
|
return idxv($this->parameters, array('fields', 'status', 'closed'));
|
||||||
}
|
}
|
||||||
|
@ -114,6 +145,14 @@ final class ArcanistRevisionRef
|
||||||
return $this->getHardpoint(self::HARDPOINT_COMMITMESSAGE);
|
return $this->getHardpoint(self::HARDPOINT_COMMITMESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAuthorRef() {
|
||||||
|
return $this->getHardpoint(self::HARDPOINT_AUTHORREF);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParentRevisionRefs() {
|
||||||
|
return $this->getHardpoint(self::HARDPOINT_PARENTREVISIONREFS);
|
||||||
|
}
|
||||||
|
|
||||||
public function getDisplayRefObjectName() {
|
public function getDisplayRefObjectName() {
|
||||||
return $this->getMonogram();
|
return $this->getMonogram();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue