From 38d11d35649851b42daf0bb455ded2e0705dae53 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 4 Jan 2017 06:56:52 +0000 Subject: [PATCH] enhanced reivision grph rendering a little --- .../src/codepot/models/subversionmodel.php | 39 +++++++++++-------- codepot/src/codepot/views/code_file.php | 19 +++++++++ codepot/src/codepot/views/code_folder.php | 31 ++++++++++++--- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index 14b83986..be57c40c 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -1638,18 +1638,25 @@ class SubversionModel extends Model return $cloc; } - private function _add_rg_node (&$nodeids, &$nodes, $name) + private function _add_rg_node (&$nodeids, &$nodes, $name, $type = '') { - if (array_key_exists($name, $nodeids)) return $nodeids[$name]; + if (array_key_exists($name, $nodeids)) + { + $nid = $nodeids[$name]; + if ($type != '') $nodes[$nid]['_type'] .= $type; + return $nid; + } + $nid = count($nodeids); - array_push ($nodes, array ('id' => $nid, 'label' => $name)); + array_push ($nodes, array ('id' => $nid, 'label' => $name, '_type' => $type)); $nodeids[$name] = $nid; return $nid; } private function _add_rg_edge (&$edges, $from, $to, $label) { - array_push ($edges, array ('from' => $from, 'to' => $to, 'label' => $label)); + $edge = array ('from' => $from, 'to' => $to, 'label' => $label); + if (!in_array($edge, $edges)) array_push ($edges, $edge); } function __revisionGraph ($projectid, $path, $rev) @@ -2059,12 +2066,12 @@ class SubversionModel extends Model if ($br >= 0) { $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}"); - $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); + $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'X'); $this->_add_rg_edge ($edges, $id1, $id2, ''); } $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); - $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); + $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'X'); $this->_add_rg_edge ($edges, $id1, $id2, 'copied'); break; case 'MV': @@ -2072,12 +2079,12 @@ class SubversionModel extends Model if ($br >= 0) { $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}"); - $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); + $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'X'); $this->_add_rg_edge ($edges, $id1, $id2, ''); } $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); - $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); + $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'X'); $this->_add_rg_edge ($edges, $id1, $id2, 'moved'); break; case 'RM': @@ -2085,18 +2092,18 @@ class SubversionModel extends Model if ($br >= 0) { $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}"); - $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); + $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'X'); $this->_add_rg_edge ($edges, $id1, $id2, ''); } - $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); - $id2 = $this->_add_rg_node ($nodeids, $nodes, $topath); - $this->_add_rg_edge ($edges, $id1, $id2, 'deleted'); + $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'D'); + //$id2 = $this->_add_rg_node ($nodeids, $nodes, $topath); + //$this->_add_rg_edge ($edges, $id1, $id2, 'deleted'); break; case 'AD': - $id1 = $this->_add_rg_node ($nodeids, $nodes, $frompath); - $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); - $this->_add_rg_edge ($edges, $id1, $id2, ''); + //$id1 = $this->_add_rg_node ($nodeids, $nodes, $frompath); + $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'A'); + //$this->_add_rg_edge ($edges, $id1, $id2, ''); break; case 'MF': /* @@ -2128,7 +2135,7 @@ class SubversionModel extends Model $torev = $ti[2]; $num_changes = $ti[3]; $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); - $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); + $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'X'); $this->_add_rg_edge ($edges, $id1, $id2, "{$num_changes} change(s)"); } diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 2821b2dc..d14bd91e 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -447,7 +447,26 @@ var RevGraphApp = (function () j = data.nodes.length; for (i = 0; i < j; i++) { + data.nodes[i].labelHighlightBold = false; data.nodes[i].shape = 'box'; + if (data.nodes[i]._type == '') + { + // no other nodes reache this node + data.nodes[i].color = '#553322'; + data.nodes[i].font = { color: 'white' }; + } + else if (data.nodes[i]._type.indexOf('D') >= 0) + { + data.nodes[i].color = '#AA3344'; + data.nodes[i].font = { color: 'white' }; + data.nodes[i].label += '\n<>'; + } + else if (data.nodes[i]._type.indexOf('A') >= 0) + { + data.nodes[i].color = '#227722'; + data.nodes[i].font = { color: 'white' }; + data.nodes[i].label += '\n<>'; + } } j = data.edges.length; diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index 592009d9..e39bb1be 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -268,7 +268,7 @@ var RevGraphApp = (function () autoResize: false, height: '400px', width: '90%', - clickToUse: false, + clickToUse: false /*, layout: { hierarchical: { enabled: true, @@ -276,8 +276,8 @@ var RevGraphApp = (function () //levelSeparation: 150, //nodeSpacing: 200, //treeSpacing: 300, - direction: 'LR', //'LR' 'UD', 'DU', 'RL' - sortMethod: 'directed' // 'hubsize'*/ + //direction: 'LR' //'LR' 'UD', 'DU', 'RL' + //sortMethod: 'directed' // 'hubsize' } }, @@ -289,17 +289,36 @@ var RevGraphApp = (function () } }, physics: { - //enabled: true - enabled: false - } + enabled: true + }*/ }; var i, j; j = data.nodes.length; + for (i = 0; i < j; i++) { + data.nodes[i].labelHighlightBold = false; data.nodes[i].shape = 'box'; + if (data.nodes[i]._type == '') + { + // no other nodes reache this node + data.nodes[i].color = '#553322'; + data.nodes[i].font = { color: 'white' }; + } + else if (data.nodes[i]._type.indexOf('D') >= 0) + { + data.nodes[i].color = '#AA3344'; + data.nodes[i].font = { color: 'white' }; + data.nodes[i].label += '\n<>'; + } + else if (data.nodes[i]._type.indexOf('A') >= 0) + { + data.nodes[i].color = '#227722'; + data.nodes[i].font = { color: 'white' }; + data.nodes[i].label += '\n<>'; + } } j = data.edges.length;