2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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 \*=====================================================================*/
25 * This class represents one revision in a given repository
28 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
53 // ###################################################################
55 * Creates a new revision for a given repository and revision
57 * @param string Repository
58 * @param integer Revision to get; to get HEAD, specify 0
60 public function __construct($repos, $rev = 0)
62 $this->path
= BSRegister
::Get('repos')->fetchPath($repos);
63 $this->repos
= $repos;
65 $this->_fetchRevision($rev);
68 // ###################################################################
70 * Returns an array of properties for this revision at a certain path
74 * @return array Array of properties
76 public function getPropsForPath($path)
78 $output = BSRegister
::Get('lib')->run('proplist -v -r' . $this->revision
. ' ' . BSRegister
::Get('lib')->arg($this->path
. $path));
82 foreach ($output AS $line)
84 if (preg_match('#^\s+(.*)\s:(\s(.*))?#', $line, $matches))
86 $curprop = $matches[1];
87 $proplist["$curprop"] = $matches[2] . "\n";
91 $proplist["$curprop"] .= $line . "\n";
98 // ###################################################################
100 * Gets the desired XML revision information from the repository
102 * @param integer Desired revision
104 private function _fetchRevision($desired)
106 $xml = BSXml
::Parse(BSRegister
::Get('lib')->run('info --xml ' . ($desired > 0 ?
'-r' . intval($desired) . ' ' : '') . BSRegister
::Get('lib')->arg($this->path
), true
));
107 $this->revision
= intval($xml['info']['entry']['commit']['revision']);
111 /*=====================================================================*\
112 || ###################################################################
115 || ###################################################################
116 \*=====================================================================*/