// ###################################################################
+$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);
// ###################################################################
-$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 = '';
{
$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"];
}
// ###################################################################
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
*
<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>