changed the code revision view to show property changes

This commit is contained in:
hyung-hwan 2015-04-13 03:41:12 +00:00
parent bd625f0cc1
commit a05f05458c
4 changed files with 184 additions and 23 deletions

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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();
}
</script>
<title><?php
@ -210,7 +217,7 @@ function render_wiki()
?></title>
</head>
<body onload="render_wiki()">
<body onload="render_wiki(); hide_unneeded_divs()">
<div class="content" id="code_revision_content">
@ -355,8 +362,9 @@ $history = $file['history'];
</pre>
</div>
<div id="code_revision_mainarea_result_files">
<div class="title"><?php print $this->lang->line('Files')?></div>
<table id="code_revision_mainarea_result_table">
<table id="code_revision_mainarea_result_files_table">
<?php
/*
print '<tr class="heading">';
@ -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 "<tr class='{$rowclass}'>";
@ -392,9 +400,73 @@ $history = $file['history'];
}
?>
</table>
</div>
<div id="code_revision_mainarea_result_properties">
<div class="title"><?php print $this->lang->line('CODE_PROPERTIES');?></div>
<table id="code_revision_mainarea_result_properties_table">
<?php
$rowclasses = array ('odd', 'even');
$rowcount = 0;
foreach ($history['paths'] as &$p)
{
if (array_key_exists('props', $p) && array_key_exists('prev_props', $p))
{
$common_props = array_intersect_assoc ($p['props'], $p['prev_props']);
$added_props = array_diff_assoc ($p['props'], $common_props);
$deleted_props = array_diff_assoc ($p['prev_props'], $common_props);
if (count($added_props) > 0 || count($deleted_props) > 0)
{
$rowclass = $rowclasses[++$rowcount % 2];
$first = TRUE;
foreach ($added_props as $k => $v)
{
print "<tr class='{$rowclass}'>";
if ($first)
{
print "<td class='{$p['action']}'>";
$xpar = $this->converter->AsciiToHex ($p['path']);
print anchor ("code/file/{$project->id}/{$xpar}/{$history['rev']}", htmlspecialchars($p['path']));
$first = FALSE;
}
else print "<td>";
print '</td>';
print '<td class="A">';
printf ('%s - %s', htmlspecialchars($k), htmlspecialchars($v));
print '</td>';
print '</tr>';
}
foreach ($deleted_props as $k => $v)
{
print "<tr class='{$rowclass}'>";
if ($first)
{
print "<td class='{$p['action']}'>";
$xpar = $this->converter->AsciiToHex ($p['path']);
print anchor ("code/file/{$project->id}/{$xpar}/{$history['rev']}", htmlspecialchars($p['path']));
$first = FALSE;
}
else print "<td>";
print '</td>';
print '<td class="D">';
printf ('%s - %s', htmlspecialchars($k), htmlspecialchars($v));
print '</td>';
print '</tr>';
}
}
}
}
?>
</table>
</div>
<div id="code_revision_mainarea_result_comments">
<div class="title"><?php print $this->lang->line('Comment')?>&nbsp;
<?php if ($is_loggedin): ?>
<span class='anchor'>
@ -437,7 +509,7 @@ $history = $file['history'];
?>
</div> <!-- code_revision_mainarea_review_comment -->
</div> <!-- code_revision_mainarea_result_comments -->
</div> <!-- code_revision_mainarea_result -->

View File

@ -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%;