Random pieces that don't work all quite yet. browse.php is getting there
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 12 Jan 2006 07:16:57 +0000 (07:16 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 12 Jan 2006 07:16:57 +0000 (07:16 +0000)
browse.php
includes/cachev.php
includes/svnlib.php
templates/default/browse.tpl

index 2903846e17eb5109259f7eca91574d8e2e5a525b..50e86cace63d955aa74ece1014921941b729ada4 100644 (file)
@@ -30,16 +30,19 @@ $navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path);
 
 // ###################################################################
 
+$node = preg_replace('#(^/|/$)#', '', ($viewsvn->paths->relpath == '' ? $viewsvn->paths->path : $viewsvn->paths->relpath));
+$latest = $cachev->fetch_latest_revision($node);
+
 $link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->revstr, $viewsvn->paths->path);
 
-$show['head'] = ($viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $viewsvn->paths->revnum AND $viewsvn->paths->revnum != 'HEAD');
+$show['head'] = ($latest['revnow'] != $viewsvn->paths->revnum AND $viewsvn->paths->revnum != 'HEAD');
 if ($show['head'])
 {
        $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $viewsvn->paths->path);
        $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->revnum), $viewsvn->paths->path);
 }
 
-$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $viewsvn->paths->revnum)) != -1 ? true : false);
+//$show['prev'] = (($prev = $cachev->fetch_prev_revision($viewsvn->paths->path, $viewsvn->paths->revnum)) != -1 ? true : false);
 if ($show['prev'])
 {
        $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->revnum, $prev), $viewsvn->paths->path);
@@ -47,10 +50,11 @@ if ($show['prev'])
 
 // ###################################################################
 
-$revinfo = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $viewsvn->paths->revnum);
-
+$revinfo = $cachev->fetch_revision($viewsvn->paths->revnum);
 $revinfo['message_clean'] = $viewsvn->svn->format_log_message($revinfo['message']);
 
+$revinfo['date'] = $viewsvn->svn->format_date_string($revinfo['dateline']);
+
 $listing = $viewsvn->svn->ls($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->revnum);
 
 $nodes = '';
index b21d73877a895b990b641acc92c085c458dbb884..f09af733c4cfed586ff229377ffab5bdf19f31bb 100644 (file)
@@ -98,12 +98,64 @@ class cacheV
        {
                $revision = $this->registry->clean($revision, TYPE_UINT);
                
-               if (!isset($this->memcache["$revision"]))
+               if (!isset($this->memcache['revs']["$revision"]))
                {
-                       $this->memcache["$revision"] = $this->registry->db->query_first("SELECT * FROM {$this->hash}_revs WHERE revision = $revision");
+                       $this->memcache['revs']["$revision"] = $this->registry->db->query_first("SELECT * FROM {$this->hash}_revs " . ($revision == 0 ? " ORDER BY revision DESC LIMIT 1" : "WHERE revision = $revision"));
+                       $this->memcache['revs']["$revision"]['files'] = unserialize($this->memcache['revs']["$revision"]['files']);
                }
                
-               return $this->memcache["$revision"];
+               return $this->memcache['revs']["$revision"];
+       }
+       
+       // ###################################################################
+       /**
+       * Returns the revision entry before the specified one
+       *
+       * @access       public
+       *
+       * @param        integer Revision number
+       *
+       * @return       array   Complete revision/commit entry
+       */
+       function fetch_prev_revision($revision)
+       {
+               static $prevrevs;
+               
+               $revision = $this->registry->clean($revision, TYPE_UINT);
+               
+               if (!isset($prevrevs["$revision"]))
+               {
+                       $result = $this->registry->db->query_first("SELECT * FROM {$this->hash}_revs ORDER BY revision DESC LIMIT 1 WHERE revision < $revision");
+                       $revision = $result['revision'];
+                       $this->memcache['revs']["$revision"] = $result;
+                       $this->memcache['revs']["$revision"]['files'] = unserialize($this->memcache['revs']["$revision"]['files']);
+               }
+               else
+               {
+                       $revision = $prevrevs["$revision"];
+               }
+               
+               return $this->memcache['revs']["$revision"];
+       }
+       
+       // ###################################################################
+       /**
+       * Fetches the latest revision for a given path
+       *
+       * @access       public
+       *
+       * @param        string  Node path
+       *
+       * @return       integer Latest revision; FALSE if none (not in HEAD)
+       */
+       function fetch_latest_revision($node)
+       {
+               if (!isset($this->memcache['nodes']["$node"]))
+               {
+                       $this->memcache['nodes']["$node"] = $this->registry->db->query_first("SELECT * FROM {$this->hash}_nodes WHERE name = '" . $this->registry->escape($node) . "'");
+               }
+               
+               return $this->memcache['nodes']["$node"];
        }
        
        // ###################################################################
index 8ed39baad0205c160ea098c1b6e845a217e9f8ac..3fd86ca4aa3e65c8f7f1bccaa749307cfa9c4a59 100644 (file)
@@ -173,6 +173,22 @@ class SVNLib
                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 14167dac38c2d619d7421bec1b8e7978b176bb46..c2c6c0733b39fd346869e5c8775592e58af5fd5b 100644 (file)
@@ -9,9 +9,9 @@ $header
 
 <div class="head">{@"Revision Information"}</div>
 <div class="content">
-       <div><strong>{@"Revision"}:</strong> $revinfo[rev]</div>
+       <div><strong>{@"Revision"}:</strong> $revinfo[revision]</div>
        <div><strong>{@"Author"}:</strong> $revinfo[author]</div>
-       <div><strong>{@"Date"}:</strong> $revinfo[date] $revinfo[timezone]</div>
+       <div><strong>{@"Date"}:</strong> $revinfo[date]</div>
        <div><strong>{@"Message"}:</strong> $revinfo[message_clean]</div>
 </div>