From 9895ff292c8d256bc4713d29ff1902fa16d51ca5 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 23 Apr 2006 20:54:19 +0000 Subject: [PATCH] Lots of brokenness --- includes/cachev.php | 93 +++++++++++++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 24 deletions(-) diff --git a/includes/cachev.php b/includes/cachev.php index 6480b44..43c041a 100644 --- a/includes/cachev.php +++ b/includes/cachev.php @@ -180,7 +180,14 @@ class cacheV $data = $this->fetch_node(); $data = $data['history']; - return max(array_keys($data)); + if (is_array($data)) + { + return max(array_keys($data)); + } + else + { + return 0; + } } // ################################################################### @@ -210,7 +217,14 @@ class cacheV return $this->fetch_revision($target); } - $keys = array_keys($data); + if (is_array($data)) + { + $keys = array_keys($data); + } + else + { + return 0; + } $prev = 0; foreach ($keys AS $id => $revnum) @@ -340,13 +354,38 @@ class cacheV $output = implode("\n", $output); $tree = $this->controller->registry->xml->parse($output); + // construct _revs inserts and the list of add revisions + foreach ($tree['log']['logentry'] AS $log) + { + XML::unify_node($log['paths']['path']); + + $inserts['revs'][] = "($log[revision], '{$log['author']['value']}', '{$log['date']['value']}', '" . $this->controller->registry->escape($log['msg']['value']) . "', '" . $this->controller->registry->escape(serialize($log['paths']['path'])) . "')"; + + foreach ($log['paths']['path'] AS $path) + { + if (trim($path['action']) == 'A') + { + $path['value'] = preg_replace('#^/#', '', $path['value']); + $addlist["$path[value]"] = $log['revision']; + } + + $filelist[] = $this->controller->repospath . $path['value'] . '@' . $log['revision']; + } + } + + $newfilelist = array(); + foreach ($filelist AS $item) + { + + } + // get _nodes - $output = $this->controller->library->svn('info --xml -R ' . $this->controller->repospath); + $output = $this->controller->library->svn('info --xml ' . implode(' ', $filelist)); $output = implode("\n", $output); $infolist = $this->controller->registry->xml->parse($output); - + // other part of _nodes: properties - $output = $this->controller->library->svn('proplist -v -R ' . $this->controller->repospath); + $output = $this->controller->library->svn('proplist -v ' . implode(' ', $filelist)); $init = false; foreach ($output AS $line) { @@ -377,23 +416,10 @@ class cacheV } } - // construct _revs inserts and the list of add revisions - foreach ($tree['log']['logentry'] AS $log) - { - $this->controller->registry->xml->unify_node($log['paths']['path']); - - $inserts['revs'][] = "($log[revision], '{$log['author']['value']}', '{$log['date']['value']}', '" . $this->controller->registry->escape($log['msg']['value']) . "', '" . $this->controller->registry->escape(serialize($log['paths']['path'])) . "')"; - - foreach ($log['paths']['path'] AS $path) - { - if (trim($path['action']) == 'A') - { - $path['value'] = preg_replace('#^/#', '', $path['value']); - $addlist["$path[value]"] = $log['revision']; - } - } - } + XML::unify_node($infolist['info']['entry']); + $nodeindex = 0; + $nodesat = array(); // construct list of HEAD nodes for _nodes foreach ($infolist['info']['entry'] AS $node) { @@ -423,13 +449,32 @@ class cacheV $path = str_replace($this->controller->repospath, '', $node['url']['value']); $path = ($path == '' ? '/' : $path); - $inserts['nodes'][] = "('$path', '" . $node['kind'] . "', " . $node['commit']['revision'] . ", '" . $this->controller->registry->escape(serialize($loglist)) . "', '" . $this->controller->registry->escape(serialize($proplist["$path"])) . "')"; + $nodesat["$path"][ $node['commit']['revision'] ] = $nodeindex; + $max = max(array_keys($nodesat["$path"])); + if ($max < $node['commit']['revision']) + { + continue; + } + else if ($max >= $node['commit']['revision']) + { + foreach ($nodesat["$path"] AS $rev => $ind) + { + if ($rev != $node['commit']['revision']) + { + unset($inserts['nodes'][ $nodesat["$path"]["$rev"] ]); + } + } + } + + $inserts['nodes']["$nodeindex"] = "('$path', '" . $node['kind'] . "', " . $node['commit']['revision'] . ", '" . $this->controller->registry->escape(serialize($loglist)) . "', '" . $this->controller->registry->escape(serialize($proplist["$path"])) . "')"; + + $nodeindex++; } if ($seps == false) { // insert _revs - $this->controller->registry->db->query(" + var_dump(" REPLACE INTO c{$this->hash}_revs (revision, author, dateline, message, files) VALUES @@ -437,7 +482,7 @@ class cacheV ); // insert _nodes - $this->controller->registry->db->query(" + var_dump(" REPLACE INTO c{$this->hash}_nodes (name, node, revision, history, properties) VALUES -- 2.22.5