From 5b662169625638acba59f8342363db78a346ae10 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 12 Jan 2006 06:07:53 +0000 Subject: [PATCH] Create the whole second cache table. This is a lot of changes :) --- includes/cachev.php | 83 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/includes/cachev.php b/includes/cachev.php index 9864c9b..dd0276a 100644 --- a/includes/cachev.php +++ b/includes/cachev.php @@ -100,7 +100,7 @@ class cacheV if (!isset($this->memcache["$revision"])) { - $this->memcache["$revision"] = $this->registry->db->query_first("SELECT * FROM {$this->hash} WHERE revision = $revision"); + $this->memcache["$revision"] = $this->registry->db->query_first("SELECT * FROM {$this->hash}_revs WHERE revision = $revision"); } return $this->memcache["$revision"]; @@ -117,7 +117,7 @@ class cacheV */ function exec_build() { - $result = $this->registry->db->query_first("SELECT MAX(revision) AS max FROM {$this->hash}"); + $result = $this->registry->db->query_first("SELECT MAX(revision) AS max FROM {$this->hash}_revs"); $this->count = $result['max']; // time to go from the start @@ -127,7 +127,7 @@ class cacheV } else { - // send an Xquery to SVN + // send an Xquery to SVN to see if we need to update $query = $this->registry->svn->svn('info --xml ' . $this->registry->repos->fetch_path($this->registry->paths->repos)); $query = implode("\n", $query); @@ -153,25 +153,94 @@ class cacheV { $start = microtime(); + // get _revs $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); + // get _nodes + $output = $this->registry->svn->svn('info --xml -R ' . ($revision !== null ? '-r' . $revision . ':HEAD ' : '') . $this->registry->repos->fetch_path($this->registry->paths->repos)); + $output = implode("\n", $output); + $infolist = $this->registry->xml->parse($output); + + // other part of _nodes + $output = $this->registry->svn->svn('proplist -v -R ' . ($revision !== null ? ' -r' . $revision . ':HEAD ' : '') . $this->registry->repos->fetch_path($this->registry->paths->repos)); + foreach ($output AS $line) + { + if (preg_match('#^Properties on \'(.*?)\':$#', $line, $bits)) + { + $proplist["$index"]["$curprop"] = trim($proplist["$index"]["$curprop"]); + $index = str_replace($this->registry->repos->fetch_path($this->registry->paths->repos), '', $bits[1]); + $capture = false; + } + else + { + if (preg_match('#^\s+(.*)\s:\s(.*)#', $line, $matches)) + { + $curprop = $matches[1]; + $proplist["$index"]["$curprop"] = $matches[2] . "\n"; + $capture = true; + } + else if ($capture == true) + { + $proplist["$index"]["$curprop"] .= $line . "\n"; + } + } + } + foreach ($tree['log']['logentry'] AS $log) { $this->registry->xml->unify_node($log['paths']['path']); - $inserts[] = "($log[revision], '{$log['author']['value']}', '{$log['date']['value']}', '" . $this->registry->escape($log['msg']['value']) . "', '" . $this->registry->escape(serialize($files)) . "')"; + $inserts['revs'][] = "($log[revision], '{$log['author']['value']}', '{$log['date']['value']}', '" . $this->registry->escape($log['msg']['value']) . "', '" . $this->registry->escape(serialize($log['paths']['path'])) . "')"; + + foreach ($log['paths']['path'] AS $path) + { + if ($path['action'] == 'A') + { + $act = 'addrevs'; + } + else if ($path['action'] == 'D') + { + $act = 'delrevs'; + } + else + { + $act = 'revs'; + } + + $path['value'] = preg_replace('#^/#', '', $path['value']); + $pathlist["$path[value]"]["$act"][] = $log['revision']; + } + } + + foreach ($infolist['info']['entry'] AS $node) + { + $inserts['nodes'][] = "('$node[path]', '{$node['repository']['uuid']['value']}', '" . implode(',', $pathlist["$node[path]"]['delrevs']) . "', '" . implode(',', $pathlist["$node[path]"]['addrevs']) . "', '" . implode(',', $pathlist["$node[path]"]['revs']) . "', '" . $this->registry->escape(serialize($proplist["$node[path]"])) . "')"; } $this->registry->db->query(" - REPLACE INTO {$this->hash} + REPLACE INTO {$this->hash}_revs (revision, author, dateline, message, files) VALUES - " . implode(",\n", $inserts) + " . implode(",\n", $inserts['revs']) ); + $this->registry->db->query(" + REPLACE INTO {$this->hash}_nodes + (name, uuid, delrevs, addrevs, revs, properties) + VALUES + " . implode(",\n", $inserts['nodes']) + ); + + /* + name VARCHAR(255) NOT NULL DEFAULT '', + uuid VARCHAR(50) NOT NULL DEFAULT '', + delrevs MEDIUMTEXT NOT NULL DEFAULT '', + addrevs MEDIUMTEXT NOT NULL DEFAULT '', + revs MEDIUMTEXT NOT NULL DEFAULT '', + properties MEDIUMTEXT NOT NULL DEFAULT '',*/ + $this->registry->debug("TIME TO (RE)BUILD: " . $this->registry->funct->fetch_microtime_diff($start)); } } -- 2.22.5