registry =& $viewsvn; } // ################################################################### /** * Sets the hash so we know what table we're dealing with * * @access public */ function set_hash() { $this->hash = md5($this->registry->repos->fetch_path($this->registry->paths->repos)); } // ################################################################### /** * Returns a specific log entry * * @access public * * @param integer Revision number * * @return array Complete revision/commit entry */ function fetch_revision($revision) { $revision = $this->registry->clean($revision, TYPE_UINT); if (!isset($this->memcache["$revision"])) { $this->memcache["$revision"] = $this->registry->db->query_first("SELECT * FROM {$this->hash} WHERE revision = $revision"); } return $this->memcache["$revision"]; } // ################################################################### /** * Checks to see if it's necessary to rebuild the cacheV table for the * current repository. This is done by making sure $count > 0. If not, * then rebuild() is run. This also checks against the cacheV table * to make sure that it's up-to-date against the root repository. * * @access public */ function exec_build() { $result = $this->registry->db->query_first("SELECT MAX(revision) AS max FROM {$this->hash}"); $this->count = $result['max']; // time to go from the start if ($this->count == 0) { $this->build(null); } else { // send an Xquery to SVN $query = $this->registry->svn->svn('info --xml ' . $this->registry->repos->fetch_path($this->registry->paths->repos)); $query = implode("\n", $query); $tree = $this->registry->xml->parse($query); if ($tree['info']['entry']['revision'] != $this->count) { $this->build($this->count); } } } // ################################################################### /** * Builds the cacheV table. This can be used to build only part of the * cache or the entire thing, if the revision is set to NULL. * * @access public * * @param integer Lower (current) revision */ function build($revision) { $start = microtime(); $output = $this->registry->svn->svn('log --xml -v ' . ($revision !== null ? '-r' . $revision . ':HEAD ' : '') . $this->registry->repos->fetch_path($this->registry->paths->repos)); $output = implode("\n", $output); $tree = $this->registry->xml->parse($output); foreach ($tree['log']['logentry'] AS $log) { if (isset($log['paths'][0])) { $files = $log['paths']['path']; } else { $files = array($log['paths']['path']); } $inserts[] = "($log[revision], '{$log['author']['value']}', '{$log['date']['value']}', '" . $this->registry->escape($log['msg']['value']) . "', '" . $this->registry->escape(serialize($files)) . "')"; } $this->registry->db->query(" INSERT INTO {$this->hash} (revision, author, dateline, message, files) VALUES " . implode(",\n", $inserts) ); $this->registry->debug("TIME TO (RE)BUILD: " . $this->registry->funct->fetch_microtime_diff($start)); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>