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
48 * The subpath inside the repository we're getting info for
60 * The commmit message for this revision
66 * The unparsed/unformatted log message
72 * Author who committed the revision
78 * The date and time this revision was made
83 // ###################################################################
85 * Creates a new revision for a given repository and revision
87 * @param string Repository
88 * @param integer Revision to get; to get HEAD, specify 0
89 * @param string Path inside the repository to get info for
91 public function __construct($repos, $rev = 0, $subpath = null
)
93 $this->path
= BSRegister
::Get('repos')->fetchPath($repos);
94 $this->repos
= $repos;
95 $this->subpath
= $subpath;
97 $this->_fetchRevision($rev);
100 // ###################################################################
102 * Returns an array of properties for this revision at a certain path
106 * @return array Array of properties
108 public function getPropsForPath($path)
110 $output = BSRegister
::Get('lib')->run('proplist -v -r' . $this->revision
. ' ' . BSRegister
::Get('lib')->arg($this->path
. $path));
114 foreach ($output AS $line)
116 if (preg_match('#^\s+(.*)\s:(\s(.*))?#', $line, $matches))
118 $curprop = $matches[1];
119 $proplist["$curprop"] = $matches[2] . "\n";
123 $proplist["$curprop"] .= $line . "\n";
130 // ###################################################################
132 * Gets the revision information (commit message, author, date) for the
135 public function getRevisionInfo()
137 $xml = BSXml
::Parse(BSRegister
::Get('lib')->run('log --xml -r' . $this->revision
. ' ' . BSRegister
::Get('lib')->arg($this->path
), true
));
138 $this->message
= FormatLogMessage($xml['log']['logentry']['msg']['value']);
139 $this->messasgeClean
= $xml['log']['logentry']['msg']['value'];
140 $this->datetime
= FormatSvnDate($xml['log']['logentry']['date']['value']);
141 $this->author
= $xml['log']['logentry']['author']['value'];
144 // ###################################################################
146 * Gets the desired XML revision information from the repository
148 * @param integer Desired revision
150 private function _fetchRevision($desired)
152 $xml = BSXml
::Parse(BSRegister
::Get('lib')->run('info --xml ' . ($desired > 0 ?
'-r' . intval($desired) . ' ' : '') . BSRegister
::Get('lib')->arg($this->path
. $this->subpath
), true
));
153 $this->revision
= intval($xml['info']['entry']['commit']['revision']);
157 /*=====================================================================*\
158 || ###################################################################
161 || ###################################################################
162 \*=====================================================================*/