From 0347cfab563c70bc68e294d35e3efac3cb9062fc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 9 Jan 2006 08:15:26 +0000 Subject: [PATCH] Checking in cacheV controller --- includes/cachev.php | 149 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 includes/cachev.php diff --git a/includes/cachev.php b/includes/cachev.php new file mode 100644 index 0000000..55f0082 --- /dev/null +++ b/includes/cachev.php @@ -0,0 +1,149 @@ +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)); + } + + // ################################################################### + /** + * 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. + * + * @access public + */ + function exec_rebuild() + { + $result = $this->registry->db->query_first("SELECT COUNT(*) AS count FROM {$this->hash}"); + if ($result['count'] > 0) + { + return; + } + + $this->rebuild(); + } + + // ################################################################### + /** + * Rebuilds the entire cacheV table from scratch. This is used on new + * repositories by checking $count. Be careful as this is a very + * expensive operation to run. + * + * @access public + */ + function rebuild() + { + $start = microtime(); + + $output = $this->registry->svn->svn('log --xml -v ' . $this->registry->repos->fetch_path($this->registry->paths->repos)); + $output = implode("\n", $output); + + $this->registry->load('xml', 'xml', true); + $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 REBUILD: " . $this->registry->funct->fetch_microtime_diff($start)); + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.43.5