From a05f05458c88b4d4ba612e9a7390242ff75f560a Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 13 Apr 2015 03:41:12 +0000 Subject: [PATCH] changed the code revision view to show property changes --- codepot/src/codepot/controllers/code.php | 68 ++++++++++++---- .../src/codepot/models/subversionmodel.php | 20 +++++ codepot/src/codepot/views/code_revision.php | 80 ++++++++++++++++++- codepot/src/css/code.css | 39 +++++++-- 4 files changed, 184 insertions(+), 23 deletions(-) diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index 1f7636b2..9b30a5f1 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -389,16 +389,8 @@ class Code extends Controller $data['popup_error_message'] = 'Invalid revision log message'; } } - } - - if ($login['id'] != '') - { - if ($this->input->post('new_review_comment')) + else if ($this->input->post('new_review_comment')) { - // Note that edit_log_message and new_review_comment are not - // supposed to be/ POSTed at the same time. - // this program may break if that happens. - $this->load->helper ('form'); $this->load->library ('form_validation'); @@ -482,6 +474,8 @@ class Code extends Controller } else { + $prev_revision = $this->subversion->getPrevRev ($projectid, $path, $rev); + if (array_key_exists('history', $file)) { // Inject the codepot defined tag. @@ -492,18 +486,64 @@ class Code extends Controller if ($h['tag'] === FALSE) $h['tag'] = ''; } else $h['tag'] = ''; + + + foreach ($h['paths'] as &$chg) + { + if ($chg['action'] == 'A' || $chg['action'] == 'M' || $chg['action'] == 'R') + { + $props = $this->subversion->listProps ($projectid, $chg['path'], $h['rev']); + if ($props === FALSE) $props = array (); + else + { + if (empty($props)) + { + $props = array(); + } + else + { + // get the first element in the associative array. + foreach ($props as &$p) break; + $props = $p; + } + } + + $prev_props = $this->subversion->listProps ($projectid, $chg['path'], $prev_revision); + if ($prev_props === FALSE) $prev_props = array (); + else + { + if (empty($prev_props)) + { + $prev_props = array(); + } + else + { + // get the first element in the associative array. + foreach ($prev_props as &$p) break; + $prev_props = $p; + } + } + + $chg['props'] = $props; + $chg['prev_props'] = $prev_props; + + //print_r ($props); + //print_r ($prev_props); + //$common_props = array_intersect_assoc($props, $prev_props); + //print_r (array_diff_assoc($props, $common_props)); // added + //print_r (array_diff_assoc($prev_props, $common_props)); // deleted + } + } } $data['project'] = $project; $data['headpath'] = $path; $data['file'] = $file; - $data['reviews'] = $reviews; + $data['reviews'] = $reviews; $data['revision'] = $rev; - $data['prev_revision'] = - $this->subversion->getPrevRev ($projectid, $path, $rev); - $data['next_revision'] = - $this->subversion->getNextRev ($projectid, $path, $rev); + $data['prev_revision'] = $prev_revision; + $data['next_revision'] = $this->subversion->getNextRev ($projectid, $path, $rev); $this->load->view ($this->VIEW_REVISION, $data); } diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index e7b4155e..04c8bb10 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -852,6 +852,26 @@ class SubversionModel extends Model return $result; } + function listProps ($projectid, $path, $rev) + { + $orgurl = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}"); + + $workurl = ($path == '')? $orgurl: "{$orgurl}@"; // trailing @ for collision prevention + $info = @svn_info ($workurl, FALSE, $rev); + + if ($info === FALSE || count($info) != 1) + { + if ($rev == SVN_REVISION_HEAD || $path == '') return FALSE; + + // rebuild the URL with a peg revision and retry it. + $workurl = "{$orgurl}@{$rev}"; + $info = @svn_info ($workurl, FALSE, $rev); + if ($info === FALSE || count($info) != 1) return FALSE; + } + + return @svn_proplist ($workurl, 0, $rev); + } + function _cloc_revision ($projectid, $path, $rev) { diff --git a/codepot/src/codepot/views/code_revision.php b/codepot/src/codepot/views/code_revision.php index 456e336c..0650b50d 100644 --- a/codepot/src/codepot/views/code_revision.php +++ b/codepot/src/codepot/views/code_revision.php @@ -200,6 +200,13 @@ function render_wiki() print "}\n"; ?> } + +function hide_unneeded_divs() +{ + // hide the properties division if its table contains no rows + var nrows = $('#code_revision_mainarea_result_properties_table tr').length; + if (nrows <= 0) $('#code_revision_mainarea_result_properties').hide(); +} <?php @@ -210,7 +217,7 @@ function render_wiki() ?> - +
@@ -355,8 +362,9 @@ $history = $file['history'];
+
lang->line('Files')?>
- +
'; @@ -367,7 +375,7 @@ $history = $file['history']; $rowclasses = array ('odd', 'even'); $rowcount = 0; - foreach ($history['paths'] as $p) + foreach ($history['paths'] as &$p) { $rowclass = $rowclasses[++$rowcount % 2]; print ""; @@ -392,9 +400,73 @@ $history = $file['history']; } ?>
+
+
+
lang->line('CODE_PROPERTIES');?>
+ + 0 || count($deleted_props) > 0) + { + $rowclass = $rowclasses[++$rowcount % 2]; + $first = TRUE; + foreach ($added_props as $k => $v) + { + print ""; + if ($first) + { + print "'; + + print ''; + print ''; + } + + foreach ($deleted_props as $k => $v) + { + print ""; + if ($first) + { + print "'; + + print ''; + print ''; + } + + } + } + } +?> +
"; + $xpar = $this->converter->AsciiToHex ($p['path']); + print anchor ("code/file/{$project->id}/{$xpar}/{$history['rev']}", htmlspecialchars($p['path'])); + $first = FALSE; + } + else print ""; + print ''; + printf ('%s - %s', htmlspecialchars($k), htmlspecialchars($v)); + print '
"; + $xpar = $this->converter->AsciiToHex ($p['path']); + print anchor ("code/file/{$project->id}/{$xpar}/{$history['rev']}", htmlspecialchars($p['path'])); + $first = FALSE; + } + else print ""; + print ''; + printf ('%s - %s', htmlspecialchars($k), htmlspecialchars($v)); + print '
+
+ +
lang->line('Comment')?>  @@ -437,7 +509,7 @@ $history = $file['history']; ?>
- +
diff --git a/codepot/src/css/code.css b/codepot/src/css/code.css index c9732659..127d5054 100644 --- a/codepot/src/css/code.css +++ b/codepot/src/css/code.css @@ -215,11 +215,11 @@ white-space: pre-wrap; } -#code_revision_mainarea_result_table td { +#code_revision_mainarea_result_files_table td { white-space: nowrap; } -#code_revision_mainarea_result_table td.M { +#code_revision_mainarea_result_files_table td.M { white-space: nowrap; background-image:url(images/page_white_edit.png); background-position:2px 50%; @@ -227,7 +227,7 @@ padding-left: 22px; } -#code_revision_mainarea_result_table td.D { +#code_revision_mainarea_result_files_table td.D { white-space: nowrap; background-image:url(images/page_white_delete.png); background-position:2px 50%; @@ -235,7 +235,7 @@ padding-left: 22px; } -#code_revision_mainarea_result_table td.A { +#code_revision_mainarea_result_files_table td.A { white-space: nowrap; background-image:url(images/page_white_add.png); background-position:2px 50%; @@ -243,7 +243,36 @@ padding-left: 22px; } -#code_revision_mainarea_result_table td.R { +#code_revision_mainarea_result_files_table td.R { + white-space: nowrap; + background-image:url(images/page_white_add.png); + background-position:2px 50%; + background-repeat:no-repeat; + padding-left: 22px; +} + +#code_revision_mainarea_result_properties_table { + border-spacing: 0; + border-collapse: collapse; +} + +#code_revision_mainarea_result_properties_table td.M { + white-space: nowrap; + background-image:url(images/page_white_edit.png); + background-position:2px 50%; + background-repeat:no-repeat; + padding-left: 22px; +} + +#code_revision_mainarea_result_properties_table td.D { + white-space: nowrap; + background-image:url(images/page_white_delete.png); + background-position:2px 50%; + background-repeat:no-repeat; + padding-left: 22px; +} + +#code_revision_mainarea_result_properties_table td.A { white-space: nowrap; background-image:url(images/page_white_add.png); background-position:2px 50%;