@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Fix an unusual nonterminating task graph node

Summary:
Fixes T12114. There were a couple of bugs here:

- We could draw too many joining lines if a node had a parent with multiple descendants.
- We could incorrectly ignore columns because of an `unset()`.

I //think// this fixes both things without collateral damage. This whole thing is a little hard to understand/debug and has grown beyond its original scope, so I'll probably rewrite it if there are more issues.

Test Plan:
- Unit tests.
- My local repro is clean now:

{F2424920}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12114

Differential Revision: https://secure.phabricator.com/D17211

+30 -7
+2 -2
src/infrastructure/diff/view/PHUIDiffGraphView.php
··· 50 50 51 51 $thread_count = $pos; 52 52 for ($n = 0; $n < $thread_count; $n++) { 53 - 54 53 if (empty($threads[$n])) { 55 54 $line .= ' '; 56 55 continue; ··· 60 59 if ($found) { 61 60 $line .= ' '; 62 61 $joins[] = $n; 63 - unset($threads[$n]); 62 + $threads[$n] = false; 64 63 } else { 65 64 $line .= 'o'; 66 65 $found = true; ··· 114 113 if ($thread_commit == $parent) { 115 114 $found = true; 116 115 $splits[] = $idx; 116 + break; 117 117 } 118 118 } 119 119
+28 -5
src/infrastructure/diff/view/__tests__/PHUIDiffGraphViewTestCase.php
··· 45 45 '^', 46 46 '|^', 47 47 'o ', 48 - '|^', 49 - '||^', 50 - 'o ', 51 - 'x', 48 + '| ^', 49 + '| |^', 50 + 'o ', 51 + 'x ', 52 52 ); 53 53 54 54 $this->assertGraph($picture, $graph, pht('Reverse Tree')); ··· 71 71 'x ', 72 72 ); 73 73 74 - $this->assertGraph($picture, $graph, pht('Reverse Tree')); 74 + $this->assertGraph($picture, $graph, pht('Terminated Tree')); 75 + } 76 + 77 + public function testThreeWayGraphJoin() { 78 + $nodes = array( 79 + 'A' => array('D', 'C', 'B'), 80 + 'B' => array('D'), 81 + 'C' => array('B', 'E', 'F'), 82 + 'D' => array(), 83 + 'E' => array(), 84 + 'F' => array(), 85 + ); 86 + 87 + $graph = $this->newGraph($nodes); 88 + $picture = array( 89 + '^', 90 + '||o', 91 + '|o|', 92 + 'x| ||', 93 + ' | x|', 94 + ' | x', 95 + ); 96 + 97 + $this->assertGraph($picture, $graph, pht('Three-Way Tree')); 75 98 } 76 99 77 100 private function newGraph(array $nodes) {