Fixing log.php
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 06:28:02 +0000 (06:28 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 06:28:02 +0000 (06:28 +0000)
includes/svnlib.php
log.php
templates/default/log_node.tpl

index b63b548e2dee76b4d2c7eeeee5a864d842922a9c..0827df0a03a40e46d7081ded2f5c669bdd0de63e 100644 (file)
@@ -282,129 +282,6 @@ class SVNBlame
        }
 }
 
-/**
-* Log management system; creates a complex list of SVN log information
-*
-* @package     ViewSVN
-* @version     $Id$
-*/
-class SVNLog
-{
-       /**
-       * Array of logs
-       * @var  array
-       * @access       private
-       */
-       var $logs = array();
-       
-       /**
-       * Raw "svn log" output
-       * @var  array
-       * @access       private
-       */
-       var $rawoutput;
-       
-       // ###################################################################
-       /**
-       * Constructor: create log store for the given file
-       *
-       * @param        object  Controller
-       */
-       function SVNLog(&$controller)
-       {
-               $this->rawoutput = $controller->library->command('log', null);
-               $this->process();
-       }
-       
-       // ###################################################################
-       /**
-       * Returns logs for display
-       *
-       * @access       public
-       *
-       * @return       array   Log data
-       */
-       function fetch()
-       {
-               return $this->logs;
-       }
-       
-       // ###################################################################
-       /**
-       * Splits up the raw output into a usable log
-       *
-       * @access       private
-       */
-       function process()
-       {
-               $lastrev = 0;
-               
-               for ($i = 1; $i <= sizeof($this->rawoutput) - 1; $i++)
-               {
-                       $line = $this->rawoutput["$i"];
-                       
-                       if (preg_match('#^r([0-9]*) \| (.*?) \| (....-..-.. ..:..:..) ([0-9\-]*) \((.*?)\) \| ([0-9]*) lines?$#', $line, $matches))
-                       {
-                               if (isset($this->logs["$lastrev"]))
-                               {
-                                       $this->logs["$lastrev"]['message'] = $this->strip_last_line($this->logs["$lastrev"]['message']);
-                               }
-                               
-                               $this->logs["$matches[1]"] = array(
-                                       'rev'           => $matches[1],
-                                       'author'        => $matches[2],
-                                       'date'          => $matches[3],
-                                       'timezone'      => $matches[4],
-                                       'lines'         => $matches[6],
-                                       'message'       => ''
-                               );
-                               
-                               $lastrev = $matches[1];
-                       }
-                       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'          => trim($matches[2]),
-                                       'from'          => (isset($amatches[2]) ? $amatches[2] : '')
-                               );
-                       }
-                       else
-                       {
-                               if (trim($line) != 'Changed paths:')
-                               {
-                                       $this->logs["$lastrev"]['message'] .= $line . "\n";
-                               }
-                       }
-               }
-               
-               if (isset($this->logs["$lastrev"]))
-               {
-                       $this->logs["$lastrev"]['message'] = $this->strip_last_line($this->logs["$lastrev"]['message']);
-               }
-       }
-       
-       // ###################################################################
-       /**
-       * Trims the last dash line off a message
-       *
-       * @access       private
-       *
-       * @param        string  Message with annoying-ass line
-       *
-       * @return       string  Clean string
-       */
-       function strip_last_line($string)
-       {
-               return trim(preg_replace("#\n(.*?)\n$#", '', $string));
-       }
-}
-
 /**
 * Diff system; constructs a diff array that is ready for output
 *
diff --git a/log.php b/log.php
index 04371a4e953e7c0f4764f771d3a4e85a936667d6..86e00898ce3324ea2c3d164c2cabf319d10d3520 100644 (file)
--- a/log.php
+++ b/log.php
@@ -24,41 +24,30 @@ $fetchtemplates = array(
        'log'
 );
 
+define('SVN', '$Id$');
+
 require_once('./global.php');
 
-$navbar = $controller->construct_breadcrumb();
+$navbar = ConstructNavbar();
 
 // ###################################################################
 
-// this is NOT supposed to allow for revision ranges
-$logs = new SVNLog($controller);
-
-$isdir = $controller->cachev->isdir();
+$logs = BSXml::Parse($lib->run('log --xml -v ' . $lib->arg($repos->fetchPath($input->in['repos']) . '/' . $input->in['path']), true));
 
 $nodes = '';
 
-foreach ($logs->fetch() AS $log)
+BSXml::UnifyNode($logs['log']['logentry']);
+
+foreach ($logs['log']['logentry'] AS $index => $log)
 {
-       $prev = $controller->cachev->fetch_prev_revision($log['rev']);
-       $prev = $prev['revision'];
+       $log['author'] = $log['author']['value'];
+       $log['date'] = FormatSvnDate($log['date']['value']);
+       $log['message_clean'] = FormatLogMessage($log['msg']['value']);
        
-       $link['view'] = $controller->href_compound(($isdir ? 'browse.php' : 'view.php'), null, Paths::fetch_rev_str(false, $log['rev']));
-       $link['blame'] = $controller->href_compound('blame.php', null, Paths::fetch_rev_str(false, $log['rev']));
+       $link['view'] = ConstructLink('view', $input->in['repos'], $input->in['path'], $log['revision']);
+       $link['blame'] = ConstructLink('blame', $input->in['repos'], $input->in['path'], $log['revision']);
+       $link['diff'] = ConstructLink('diff', $input->in['repos'], $input->in['path'], $log['revision']);
        
-       $show['diffhead'] = $controller->cachev->fetch_head_revision() != $log['rev'];
-       if ($show['diffhead'])
-       {
-               $link['diffhead'] = $controller->href_compound('diff.php', null, Paths::fetch_rev_str(true, 'HEAD', $log['rev']));
-       }
-       
-       $show['diffprev'] = ($prev !== null);
-       if ($show['diffprev'])
-       {
-               $link['diffprev'] = $controller->href_compound('diff.php', null, Paths::fetch_rev_str(true, $log['rev'], $prev));
-       }
-       
-       $log['message_clean'] = SVNCommon::format_log_message($log['message']);
-
        eval('$nodes .= "' . $template->fetch('log_node') . '";');
 }
 
index 4a71f8351e586f0255999ac3ad79e6df35101d16..5690a94717784d4bb84e8eeddfbd1a9b1db65354 100644 (file)
@@ -1,10 +1,9 @@
 <div class="subhead" style="border-width: 0px 1px 0px 1px">
-       r$log[rev] ($log[author])
-       $log[date] $log[timezone]
+       r$log[revision] ($log[author])
+       $log[date]
        - <a href="$link[view]">{@"View"}</a>
        <if condition="!$isdir">- <a href="$link[blame]">{@"Blame"}</a></if>
-       <if condition="$show['diffhead']">- <a href="$link[diffhead]">{@"Diff to HEAD"}</a></if>
-       <if condition="$show['diffprev']">- <a href="$link[diffprev]">{@"Diff to PREV"}</a></if>
+       - <a href="$link[diff]">{@"Changes"}</a></if>
 </div>
 <div class="content" style="padding: 4px">
 $log[message_clean]