Page MenuHomePhabricator

D21311.id.diff
No OneTemporary

D21311.id.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -400,7 +400,9 @@
'ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase.php',
'ArcanistReusedIteratorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistReusedIteratorXHPASTLinterRule.php',
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorXHPASTLinterRuleTestCase.php',
+ 'ArcanistRevisionAuthorHardpointQuery' => 'ref/revision/ArcanistRevisionAuthorHardpointQuery.php',
'ArcanistRevisionCommitMessageHardpointQuery' => 'ref/revision/ArcanistRevisionCommitMessageHardpointQuery.php',
+ 'ArcanistRevisionParentRevisionRefsHardpointQuery' => 'ref/revision/ArcanistRevisionParentRevisionRefsHardpointQuery.php',
'ArcanistRevisionRef' => 'ref/revision/ArcanistRevisionRef.php',
'ArcanistRevisionRefSource' => 'ref/ArcanistRevisionRefSource.php',
'ArcanistRevisionSymbolRef' => 'ref/revision/ArcanistRevisionSymbolRef.php',
@@ -1390,7 +1392,9 @@
'ArcanistReusedIteratorReferenceXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistReusedIteratorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
+ 'ArcanistRevisionAuthorHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistRevisionCommitMessageHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
+ 'ArcanistRevisionParentRevisionRefsHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistRevisionRef' => array(
'ArcanistRef',
'ArcanistDisplayRefInterface',
diff --git a/src/ref/revision/ArcanistRevisionAuthorHardpointQuery.php b/src/ref/revision/ArcanistRevisionAuthorHardpointQuery.php
new file mode 100644
--- /dev/null
+++ b/src/ref/revision/ArcanistRevisionAuthorHardpointQuery.php
@@ -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);
+ }
+
+}
diff --git a/src/ref/revision/ArcanistRevisionParentRevisionRefsHardpointQuery.php b/src/ref/revision/ArcanistRevisionParentRevisionRefsHardpointQuery.php
new file mode 100644
--- /dev/null
+++ b/src/ref/revision/ArcanistRevisionParentRevisionRefsHardpointQuery.php
@@ -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);
+ }
+
+}
diff --git a/src/ref/revision/ArcanistRevisionRef.php b/src/ref/revision/ArcanistRevisionRef.php
--- a/src/ref/revision/ArcanistRevisionRef.php
+++ b/src/ref/revision/ArcanistRevisionRef.php
@@ -6,6 +6,8 @@
ArcanistDisplayRefInterface {
const HARDPOINT_COMMITMESSAGE = 'ref.revision.commitmessage';
+ const HARDPOINT_AUTHORREF = 'ref.revision.authorRef';
+ const HARDPOINT_PARENTREVISIONREFS = 'ref.revision.parentRevisionRefs';
private $parameters;
private $sources = array();
@@ -15,8 +17,13 @@
}
protected function newHardpoints() {
+ $object_list = new ArcanistObjectListHardpoint();
return array(
$this->newHardpoint(self::HARDPOINT_COMMITMESSAGE),
+ $this->newHardpoint(self::HARDPOINT_AUTHORREF),
+ $this->newTemplateHardpoint(
+ self::HARDPOINT_PARENTREVISIONREFS,
+ $object_list),
);
}
@@ -63,6 +70,30 @@
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() {
return idxv($this->parameters, array('fields', 'status', 'closed'));
}
@@ -114,6 +145,14 @@
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() {
return $this->getMonogram();
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 24, 11:07 PM (15 h, 39 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7044673
Default Alt Text
D21311.id.diff (7 KB)

Event Timeline