From 7a3d14ee6c275fe71145d29e085be9ac032a9336 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 11 Sep 2005 19:28:39 +0000 Subject: [PATCH] Show colour file change blocks --- diff.php | 6 ++- includes/svnlib.php | 65 ++++++++++++++++++++++++++++++- templates/default/diff.tpl | 5 +++ templates/default/file.css | 62 +++++++++++++++++++++++++++++ templates/default/file_change.tpl | 1 + 5 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 templates/default/file.css create mode 100644 templates/default/file_change.tpl diff --git a/diff.php b/diff.php index 2cbab32..ab7a503 100644 --- a/diff.php +++ b/diff.php @@ -23,7 +23,8 @@ $fetchtemplates = array( 'diff_line', 'diff_hunk', 'diff_file', - 'diff' + 'diff', + 'file_change' ); require_once('./global.php'); @@ -52,6 +53,8 @@ $log = $viewsvn->svn->common->fetch_log($path, $high); $log['message_clean'] = nl2br(htmlspecialchars($log['message'])); +$files = $viewsvn->svn->common->construct_file_changes($log['files'], $repos, $high); + // ################################################################### if ($high == 'HEAD') @@ -115,6 +118,7 @@ foreach ($diff->fetch() AS $filename => $file) // ################################################################### +//echo('$template->flush("' . $template->fetch('diff') . '");'); eval('$template->flush("' . $template->fetch('diff') . '");'); /*=====================================================================*\ diff --git a/includes/svnlib.php b/includes/svnlib.php index c208c47..1cf8444 100644 --- a/includes/svnlib.php +++ b/includes/svnlib.php @@ -519,6 +519,63 @@ class SVNCommon return null; } } + + /** + * Prints the file changed list + * + * @access public + * + * @public array List of file changes + * @public string The repository + * @public integer Current revision + * + * @return string Processed HTML + */ + function construct_file_changes($changes, $repos, $revision) + { + global $viewsvn; + + $files = ''; + + foreach ($changes AS $file) + { + switch ($file['action']) + { + case 'A': + $class = 'file_add'; + $tooltip = 'Added'; + break; + case 'D': + $class = 'file_delete'; + $tooltip = 'Deleted'; + break; + case 'M': + $class = 'file_modify'; + $tooltip = 'Modified'; + break; + case 'R': + $class = 'file_replace'; + $tooltip = 'Replaced'; + break; + } + + $show['from'] = (bool)$file['from']; + + if ($file['from']) + { + $class = 'file_move'; + $tooltip = 'Moved/Copied'; + preg_match('#(.*):([0-9]+)#', $file['from'], $matches); + $link['from'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $matches[2]), $repos . $matches[1]); + } + + $link['file'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $revision), $file['file']); + + eval('$files .= "' . $viewsvn->template->fetch('file_change') . '";'); + } + + return $files; + } } /** @@ -685,9 +742,15 @@ class SVNLog } else if (preg_match('#^\s+([ADMR])\s(.*)#', $line, $matches)) { + if (preg_match('#(.*) \(from (.*?)\)$#', $matches[2], $amatches)) + { + $matches[2] = $amatches[1]; + } + $this->logs["$lastrev"]['files'][] = array( 'action' => $matches[1], - 'file' => $matches[2] + 'file' => trim($matches[2]), + 'from' => (isset($amatches[2]) ? $amatches[2] : '') ); } else diff --git a/templates/default/diff.tpl b/templates/default/diff.tpl index cbf5f36..34696cd 100644 --- a/templates/default/diff.tpl +++ b/templates/default/diff.tpl @@ -3,6 +3,7 @@ $doctype $headinclude + Diff @@ -24,6 +25,10 @@ $header
Date: $log[date] $log[timezone]
Message: $log[message_clean]
+
File Changes
+
+$files +

diff --git a/templates/default/file.css b/templates/default/file.css new file mode 100644 index 0000000..ab7f8ed --- /dev/null +++ b/templates/default/file.css @@ -0,0 +1,62 @@ +/*=====================================================================*\ +|| ################################################################### +|| # ViewSVN [#]version[#] +|| # Copyright ©2002-[#]year[#] Iris Studios, Inc. +|| # +|| # This program is free software; you can redistribute it and/or modify +|| # it under the terms of the GNU General Public License as published by +|| # the Free Software Foundation; version [#]gpl[#] of the License. +|| # +|| # This program is distributed in the hope that it will be useful, but +|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +|| # more details. +|| # +|| # You should have received a copy of the GNU General Public License along +|| # with this program; if not, write to the Free Software Foundation, Inc., +|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +|| ################################################################### +\*=====================================================================*/ + +.file_bit +{ + width: 12px; + height: 12px; + + display: inline; + float: left; + + border-color: rgb(153, 153, 153); + border-width: 1px; + border-style: solid; + + margin-top: 1px; + margin-right: 5px; +} + +.file_add +{ + background-color: rgb(187, 255, 187); +} + +.file_modify +{ + background-color: rgb(255, 221, 136); +} + +.file_delete +{ + background-color: rgb(255, 136, 136); +} + +.file_move +{ + background-color: rgb(136, 136, 255); +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ \ No newline at end of file diff --git a/templates/default/file_change.tpl b/templates/default/file_change.tpl new file mode 100644 index 0000000..3f8b6f9 --- /dev/null +++ b/templates/default/file_change.tpl @@ -0,0 +1 @@ +
$file[file] (from $file[from])
-- 2.43.5