2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * File container for cacheV class
31 * This class is responsible for interacting with a given cacheV table.
32 * It controls rebuilding from scratch, updates, and querying the cache.
34 * @author Iris Studios, Inc.
35 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
55 * Record count - the number of records in cacheV
60 // ###################################################################
62 * Constructor: initialies the registry
67 $this->registry
=& $viewsvn;
70 // ###################################################################
72 * Sets the hash so we know what table we're dealing with
78 $this->hash
= md5($this->registry
->repos
->fetch_path($this->registry
->paths
->repos
));
81 // ###################################################################
83 * Checks to see if it's necessary to rebuild the cacheV table for the
84 * current repository. This is done by making sure $count > 0. If not,
85 * then rebuild() is run.
89 function exec_rebuild()
91 $result = $this->registry
->db
->query_first("SELECT COUNT(*) AS count FROM {$this->hash}");
92 if ($result['count'] > 0)
100 // ###################################################################
102 * Rebuilds the entire cacheV table from scratch. This is used on new
103 * repositories by checking $count. Be careful as this is a very
104 * expensive operation to run.
110 $start = microtime();
112 $output = $this->registry
->svn
->svn('log --xml -v ' . $this->registry
->repos
->fetch_path($this->registry
->paths
->repos
));
113 $output = implode("\n", $output);
115 $this->registry
->load('xml', 'xml', true
);
116 $tree = $this->registry
->xml
->parse($output);
118 foreach ($tree['log']['logentry'] AS $log)
120 if (isset($log['paths'][0]))
122 $files = $log['paths']['path'];
126 $files = array($log['paths']['path']);
129 $inserts[] = "($log[revision], '{$log['author']['value']}', '{$log['date']['value']}', '" . $this->registry
->escape($log['msg']['value']) . "', '" . $this->registry
->escape(serialize($files)) . "')";
132 $this->registry
->db
->query("
133 INSERT INTO {$this->hash}
134 (revision, author, dateline, message, files)
136 " . implode(",\n", $inserts)
139 $this->registry
->debug("TIME TO REBUILD: " . $this->registry
->funct
->fetch_microtime_diff($start));
143 /*=====================================================================*\
144 || ###################################################################
147 || ###################################################################
148 \*=====================================================================*/