Show colour file change blocks
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 11 Sep 2005 19:28:39 +0000 (19:28 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 11 Sep 2005 19:28:39 +0000 (19:28 +0000)
diff.php
includes/svnlib.php
templates/default/diff.tpl
templates/default/file.css [new file with mode: 0644]
templates/default/file_change.tpl [new file with mode: 0644]

index 2cbab32f50ed222ca23b3086b56321e92ae71888..ab7a503ef0f2ebcd036c4d268d1a77c700ecaa78 100644 (file)
--- 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') . '");');
 
 /*=====================================================================*\
index c208c47dd221e7da8d215a46e9a4350ba11e2eac..1cf844435fe1e4ca06ebdcd2f377b53c5ea788f3 100644 (file)
@@ -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
index cbf5f36eb88c1502c6c7dc1108cd8bb457b49cb4..34696cd1f7dcbd660d4ae8c7f37f1bf44b0d5883 100644 (file)
@@ -3,6 +3,7 @@ $doctype
 <head>
 $headinclude
        <link rel="stylesheet" href="$viewsvn->path/templates/default/diff.css" media="screen" />
+       <link rel="stylesheet" href="$viewsvn->path/templates/default/file.css" media="screen" />
        <title>Diff</title>
 </head>
 
@@ -24,6 +25,10 @@ $header
        <div><strong>Date:</strong> $log[date] $log[timezone]</div>
        <div><strong>Message:</strong> $log[message_clean]</div>
 </div>
+<div class="subhead" style="border-width: 0px 1px 0px 1px">File Changes</div>
+<div class="content">
+$files
+</div>
 
 <br />
 
diff --git a/templates/default/file.css b/templates/default/file.css
new file mode 100644 (file)
index 0000000..ab7f8ed
--- /dev/null
@@ -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 (file)
index 0000000..3f8b6f9
--- /dev/null
@@ -0,0 +1 @@
+       <div><div class="file_bit + $class" title="$tooltip"></div> <a href="$viewsvn->path/$link[file]">$file[file]</a> <if condition="$show['from']"><em>(from <a href="$viewsvn->path/$link[from]">$file[from]</a>)</em></if></div>