diff --git a/src/infrastructure/diff/view/PHUIDiffGraphView.php b/src/infrastructure/diff/view/PHUIDiffGraphView.php index ed4b0acf57..76ae0b2045 100644 --- a/src/infrastructure/diff/view/PHUIDiffGraphView.php +++ b/src/infrastructure/diff/view/PHUIDiffGraphView.php @@ -50,7 +50,6 @@ final class PHUIDiffGraphView extends Phobject { $thread_count = $pos; for ($n = 0; $n < $thread_count; $n++) { - if (empty($threads[$n])) { $line .= ' '; continue; @@ -60,7 +59,7 @@ final class PHUIDiffGraphView extends Phobject { if ($found) { $line .= ' '; $joins[] = $n; - unset($threads[$n]); + $threads[$n] = false; } else { $line .= 'o'; $found = true; @@ -114,6 +113,7 @@ final class PHUIDiffGraphView extends Phobject { if ($thread_commit == $parent) { $found = true; $splits[] = $idx; + break; } } diff --git a/src/infrastructure/diff/view/__tests__/PHUIDiffGraphViewTestCase.php b/src/infrastructure/diff/view/__tests__/PHUIDiffGraphViewTestCase.php index 9bcf9645a3..2b9e4f8097 100644 --- a/src/infrastructure/diff/view/__tests__/PHUIDiffGraphViewTestCase.php +++ b/src/infrastructure/diff/view/__tests__/PHUIDiffGraphViewTestCase.php @@ -45,10 +45,10 @@ final class PHUIDiffGraphViewTestCase extends PhabricatorTestCase { '^', '|^', 'o ', - '|^', - '||^', - 'o ', - 'x', + '| ^', + '| |^', + 'o ', + 'x ', ); $this->assertGraph($picture, $graph, pht('Reverse Tree')); @@ -71,7 +71,30 @@ final class PHUIDiffGraphViewTestCase extends PhabricatorTestCase { 'x ', ); - $this->assertGraph($picture, $graph, pht('Reverse Tree')); + $this->assertGraph($picture, $graph, pht('Terminated Tree')); + } + + public function testThreeWayGraphJoin() { + $nodes = array( + 'A' => array('D', 'C', 'B'), + 'B' => array('D'), + 'C' => array('B', 'E', 'F'), + 'D' => array(), + 'E' => array(), + 'F' => array(), + ); + + $graph = $this->newGraph($nodes); + $picture = array( + '^', + '||o', + '|o|', + 'x| ||', + ' | x|', + ' | x', + ); + + $this->assertGraph($picture, $graph, pht('Three-Way Tree')); } private function newGraph(array $nodes) {