Page MenuHomePhabricator

D16218.diff
No OneTemporary

D16218.diff

diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php
--- a/src/applications/differential/controller/DifferentialRevisionViewController.php
+++ b/src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -344,6 +344,7 @@
$stack_graph = id(new DifferentialRevisionGraph())
->setViewer($viewer)
->setSeedPHID($revision->getPHID())
+ ->setLoadEntireGraph(true)
->loadGraph();
if (!$stack_graph->isEmpty()) {
$stack_table = $stack_graph->newGraphTable();
diff --git a/src/infrastructure/graph/PhabricatorObjectGraph.php b/src/infrastructure/graph/PhabricatorObjectGraph.php
--- a/src/infrastructure/graph/PhabricatorObjectGraph.php
+++ b/src/infrastructure/graph/PhabricatorObjectGraph.php
@@ -5,8 +5,10 @@
private $viewer;
private $edges = array();
+ private $edgeReach = array();
private $seedPHID;
private $objects;
+ private $loadEntireGraph = false;
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
@@ -29,6 +31,7 @@
final public function setSeedPHID($phid) {
$this->seedPHID = $phid;
+ $this->edgeReach[$phid] = array_fill_keys($this->getEdgeTypes(), true);
return $this->addNodes(
array(
@@ -41,7 +44,30 @@
}
final public function getEdges($type) {
- return idx($this->edges, $type, array());
+ $edges = idx($this->edges, $type, array());
+
+ // Remove any nodes which we never reached. We can get these when loading
+ // only part of the graph: for example, they point at other subtasks of
+ // parents or other parents of subtasks.
+ $nodes = $this->getNodes();
+ foreach ($edges as $src => $dsts) {
+ foreach ($dsts as $key => $dst) {
+ if (!isset($nodes[$dst])) {
+ unset($edges[$src][$key]);
+ }
+ }
+ }
+
+ return $edges;
+ }
+
+ final public function setLoadEntireGraph($load_entire_graph) {
+ $this->loadEntireGraph = $load_entire_graph;
+ return $this;
+ }
+
+ final public function getLoadEntireGraph() {
+ return $this->loadEntireGraph;
}
final protected function loadEdges(array $nodes) {
@@ -53,6 +79,8 @@
$query->execute();
+ $whole_graph = $this->getLoadEntireGraph();
+
$map = array();
foreach ($nodes as $node) {
$map[$node] = array();
@@ -64,7 +92,10 @@
$this->edges[$edge_type][$node] = $dst_phids;
foreach ($dst_phids as $dst_phid) {
- $map[$node][] = $dst_phid;
+ if ($whole_graph || isset($this->edgeReach[$node][$edge_type])) {
+ $map[$node][] = $dst_phid;
+ }
+ $this->edgeReach[$dst_phid][$edge_type] = true;
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 9:17 AM (17 h, 46 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921002
Default Alt Text
D16218.diff (2 KB)

Event Timeline