We now can get revision information:
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 05:22:05 +0000 (05:22 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 05:22:05 +0000 (05:22 +0000)
- Added Revision::getRevisionInfo()
- Revision now takes an optional subpath, which allows us to find the most recent change revision
- Added FormatLogMessage()
- Added FormatSvnDate()

browse.php
includes/class_revision.php
includes/functions.php
includes/svncommon.php
templates/default/browse.tpl
templates/default/view.tpl
view.php

index c892d2212b84cfca2c417baa329280bd7a24b7a9..2fb0eeab9a722e13b0ecb5613ec7ebeaef62dd3b 100644 (file)
@@ -33,7 +33,7 @@ $navbar = ConstructNavbar();
 
 // ###################################################################
 
-$revision = new Revision($input->in['repos'], $input->in['rev']);
+$revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
 
 // ###################################################################
 
@@ -43,8 +43,7 @@ $proplist = FormatPropList($props);
 
 // ###################################################################
 
-// $revinfo['message_clean'] = SVNCommon::format_log_message($revinfo['message']);
-// $revinfo['date'] = SVNCommon::format_date_string($revinfo['dateline']);
+$revision->getRevisionInfo();
 
 $listing = BSXml::Parse($lib->run('ls --xml -r' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . $input->in['path']), true));
 
index 02e869344e8153799c89b2d48bbb859ee9e76ca3..bec4459eda83f8aaa14fec84c6b412d9f5c05754 100644 (file)
@@ -44,23 +44,55 @@ class Revision
        */
        private $repos;
        
+       /**
+       * The subpath inside the repository we're getting info for
+       * @var string
+       */
+       private $subpath;
+       
        /**
        * The revision number
        * @var integer
        */
        public $revision;
        
+       /**
+       * The commmit message for this revision
+       * @var string
+       */
+       public $message;
+       
+       /**
+       * The unparsed/unformatted log message
+       * @var string
+       */
+       public $messageClean;
+       
+       /**
+       * Author who committed the revision
+       * @var string
+       */
+       public $author;
+       
+       /**
+       * The date and time this revision was made
+       * @var string
+       */
+       public $datetime;
+       
        // ###################################################################
        /**
        * Creates a new revision for a given repository and revision
        *
        * @param        string  Repository
        * @param        integer Revision to get; to get HEAD, specify 0
+       * @param        string  Path inside the repository to get info for
        */
-       public function __construct($repos, $rev = 0)
+       public function __construct($repos, $rev = 0, $subpath = null)
        {
                $this->path = BSRegister::Get('repos')->fetchPath($repos);
                $this->repos = $repos;
+               $this->subpath = $subpath;
                
                $this->_fetchRevision($rev);
        }
@@ -95,6 +127,20 @@ class Revision
                return $proplist;
        }
        
+       // ###################################################################
+       /**
+       * Gets the revision information (commit message, author, date) for the
+       * revision
+       */
+       public function getRevisionInfo()
+       {
+               $xml = BSXml::Parse(BSRegister::Get('lib')->run('log --xml -r' . $this->revision . ' ' . BSRegister::Get('lib')->arg($this->path), true));
+               $this->message = FormatLogMessage($xml['log']['logentry']['msg']['value']);
+               $this->messasgeClean = $xml['log']['logentry']['msg']['value'];
+               $this->datetime = FormatSvnDate($xml['log']['logentry']['date']['value']);
+               $this->author = $xml['log']['logentry']['author']['value'];
+       }
+       
        // ###################################################################
        /**
        * Gets the desired XML revision information from the repository
@@ -103,7 +149,7 @@ class Revision
        */
        private function _fetchRevision($desired)
        {
-               $xml = BSXml::Parse(BSRegister::Get('lib')->run('info --xml ' . ($desired > 0 ? '-r' . intval($desired) . ' ' : '') . BSRegister::Get('lib')->arg($this->path), true));
+               $xml = BSXml::Parse(BSRegister::Get('lib')->run('info --xml ' . ($desired > 0 ? '-r' . intval($desired) . ' ' : '') . BSRegister::Get('lib')->arg($this->path . $this->subpath), true));
                $this->revision = intval($xml['info']['entry']['commit']['revision']);
        }
 }
index ccdd8dc55b832af8fd4be3f6d4c4d73ce43c0287..808159f0c66b485c7865e6f159c561335f0371a7 100644 (file)
@@ -69,6 +69,83 @@ function FormatPropList($props)
        return $proplist;
 }
 
+// ###################################################################
+/**
+* Formats a SVN log message
+*
+* @param       string  Unformatted log message
+*
+* @return      string  Output-ready log message
+*/
+function FormatLogMessage($message)
+{
+       global $viewsvn;
+       
+       $message = BSRegister::Get('input')->entityEncode($message);
+       
+       // TODO - fix the revision links
+       // $message = preg_replace('#r([0-9]+)#e', '"<a href=\"" . $viewsvn->maincontrol->href_struct("diff.php" . Paths::fetch_rev_str(true, "\1", 0), "/") . "\">r\1</a>"', $message);
+       
+       $list = false;
+       $lines = explode("\n", $message);
+       $message = '';
+       foreach ($lines AS $line)
+       {
+               if (preg_match('#^\s*?(\*|\-)\s?(.*)#', $line, $matches))
+               {
+                       if ($list)
+                       {
+                               $message .= '<li>' . $matches[2] . '</li>';
+                       }
+                       else
+                       {
+                               $message .= '<ul class="list">';
+                               $message .= '<li>' . $matches[2] . '</li>';
+                       }
+                       $list = true;
+               }
+               else
+               {
+                       if ($list)
+                       {
+                               $message .= '</ul>';
+                               $message .= $line;
+                       }
+                       else
+                       {
+                               $message .= $line;
+                               $message .= '<br />';
+                       }
+                       $list = false;
+               }
+               
+               $message .= "\n";
+       }
+       
+       if ($list)
+       {
+               $message .= '</ul>';
+       }
+       
+       $message = preg_replace('#(<br />)*$#', '', $message);
+       
+       return $message;
+}
+
+// ###################################################################
+/**
+* Parses a date from SVN into something more human-friendly
+*
+* @param       string  Date string
+*
+* @return      string  Formatted and readable date string
+*/
+function FormatSvnDate($string)
+{
+       // 2005-01-23T20:42:53.703057Z
+       return preg_replace('#(....)\-(..)\-(..)T(..):(..):(..).(.*)Z#e', 'gmdate("r", mktime(\4, \5, \6, \2, \3, \1))', $string);
+}
+
 /*=====================================================================*\
 || ###################################################################
 || # $HeadURL$
index c7781edc8ff4e927b8e0cda80a83e6cc99729d76..f9ffa8d113967d0ff51e7b70dd6c645eeb11b252 100644 (file)
@@ -73,86 +73,6 @@ class SVNCommon
                return $string;
        }
        
-       // ###################################################################
-       /**
-       * Formats a SVN log message
-       *
-       * @access       public
-       *
-       * @param        string  Unformatted log message
-       *
-       * @return       string  Output-ready log message
-       */
-       function format_log_message($message)
-       {
-               global $viewsvn;
-               
-               $message = $viewsvn->entity_encode($message);
-               
-               $message = preg_replace('#r([0-9]+)#e', '"<a href=\"" . $viewsvn->maincontrol->href_struct("diff.php" . Paths::fetch_rev_str(true, "\1", 0), "/") . "\">r\1</a>"', $message);
-               
-               $list = false;
-               $lines = explode("\n", $message);
-               $message = '';
-               foreach ($lines AS $line)
-               {
-                       if (preg_match('#^\s*?(\*|\-)\s?(.*)#', $line, $matches))
-                       {
-                               if ($list)
-                               {
-                                       $message .= '<li>' . $matches[2] . '</li>';
-                               }
-                               else
-                               {
-                                       $message .= '<ul class="list">';
-                                       $message .= '<li>' . $matches[2] . '</li>';
-                               }
-                               $list = true;
-                       }
-                       else
-                       {
-                               if ($list)
-                               {
-                                       $message .= '</ul>';
-                                       $message .= $line;
-                               }
-                               else
-                               {
-                                       $message .= $line;
-                                       $message .= '<br />';
-                               }
-                               $list = false;
-                       }
-                       
-                       $message .= "\n";
-               }
-               
-               if ($list)
-               {
-                       $message .= '</ul>';
-               }
-               
-               $message = preg_replace('#(<br />)*$#', '', $message);
-               
-               return $message;
-       }
-       
-       // ###################################################################
-       /**
-       * Parses a date from Xquery XML outut
-       *
-       * @access       public
-       *
-       * @param        string  Date string
-       *
-       * @return       string  Formatted and readable date string
-       */
-       function format_date_string($string)
-       {
-               // 2005-01-23T20:42:53.703057Z
-               return preg_replace('#(....)\-(..)\-(..)T(..):(..):(..).(.*)Z#e', 'gmdate("r", mktime(\4, \5, \6, \2, \3, \1))', $string);
-       }
-       
        // ###################################################################
        /**
        * Counts the spaces and replaces two or more ones
index 27c16d1bf68d9f94f69fdd71e0832d6e8ea31040..37274a50acc034cc3b73b26acce0f020792bb257 100644 (file)
@@ -9,10 +9,10 @@ $header
 
 <div class="head">{@"Revision Information"}</div>
 <div class="content">
-       <div><strong>{@"Revision"}:</strong> $revinfo[revision]</div>
-       <div><strong>{@"Author"}:</strong> $revinfo[author]</div>
-       <div><strong>{@"Date"}:</strong> $revinfo[date]</div>
-       <div><strong>{@"Message"}:</strong> $revinfo[message_clean]</div>
+       <div><strong>{@"Revision"}:</strong> $revision->revision</div>
+       <div><strong>{@"Author"}:</strong> $revision->author</div>
+       <div><strong>{@"Date"}:</strong> $revision->datetime</div>
+       <div><strong>{@"Message"}:</strong> $revision->message</div>
 </div>
 
 <div class="head" style="border-width: 0px 1px 1px 1px">
index e4f2401c1057c0e6fa77e62527d6ad6f607f7d0f..b55337fd139f9969f1764fbe8093ed3daa6d92fd 100644 (file)
@@ -10,10 +10,10 @@ $header
 
 <div class="head">{@"Revision Information"}</div>
 <div class="content">
-       <div><strong>{@"Revision"}:</strong> $logmsg[revision]</div>
-       <div><strong>{@"Author"}:</strong> $logmsg[author]</div>
-       <div><strong>{@"Date"}:</strong> $logmsg[date]</div>
-       <div><strong>{@"Message"}:</strong> $logmsg[message_clean]</div>
+       <div><strong>{@"Revision"}:</strong> $revision->revision</div>
+       <div><strong>{@"Author"}:</strong> $revision->author</div>
+       <div><strong>{@"Date"}:</strong> $revision->datetime</div>
+       <div><strong>{@"Message"}:</strong> $revision->message</div>
 </div>
 
 <div class="head" style="border-width: 0px 1px 0px 1px">
index e45180f2563d0bdda22a3b7329cbb2b8d637ed95..4475bc8235ce38da907e80313ab9640722862cad 100644 (file)
--- a/view.php
+++ b/view.php
@@ -32,15 +32,11 @@ $navbar = ConstructNavbar();
 
 // ###################################################################
 
-$revision = new Revision($input->in['repos'], $input->in['rev']);
+$revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
 
 // ###################################################################
 
-/*$logmsg = $controller->cachev->fetch_revision($controller->revctx);
-unset($logmsg['files']);
-
-$logmsg['message_clean'] = SVNCommon::format_log_message($logmsg['message']);
-$logmsg['date'] = SVNCommon::format_date_string($logmsg['dateline']);*/
+$revision->getRevisionInfo();
 
 $catdata = $lib->run('cat -r' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . $input->in['path']), true);