]>
src.bluestatic.org Git - viewsvn.git/blob - includes/class_revision.php
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
84 * Files changed by the revision
87 public $files = array();
89 // ###################################################################
91 * Creates a new revision for a given repository and revision
93 * @param string Repository
94 * @param integer Revision to get; to get HEAD, specify 0
95 * @param string Path inside the repository to get info for
97 public function __construct($repos, $rev = 0, $subpath = null)
99 $this->path
= BSRegister
::Get('repos')->fetchPath($repos);
100 $this->repos
= $repos;
101 $this->subpath
= $subpath;
103 $this->_fetchRevision($rev);
106 // ###################################################################
108 * Returns an array of properties for this revision at a certain path
112 * @return array Array of properties
114 public function getPropsForPath($path)
116 $output = BSRegister
::Get('lib')->run('proplist -v -r' . $this->revision
. ' ' . BSRegister
::Get('lib')->arg($this->path
. $path) . '@' . $this->revision
);
120 foreach ($output AS $line)
122 if (preg_match('#^\s+(.*)\s:(\s(.*))?#', $line, $matches))
124 $curprop = $matches[1];
125 $proplist["$curprop"] = $matches[2] . "\n
";
129 $proplist["$curprop"] .= $line . "\n";
136 // ###################################################################
138 * Gets the revision information (commit message, author, date) for the
141 public function getRevisionInfo()
143 $xml = BSXml
::Parse(BSRegister
::Get('lib')->run('log --xml -v -r' . $this->revision
. ' ' . BSRegister
::Get('lib')->arg($this->path
) . '@' . $this->revision
, true));
144 $this->message
= FormatLogMessage($xml['log']['logentry']['msg']['value']);
145 $this->messasgeClean
= $xml['log']['logentry']['msg']['value'];
146 $this->datetime
= FormatSvnDate($xml['log']['logentry']['date']['value']);
147 $this->author
= $xml['log']['logentry']['author']['value'];
148 $this->files
= $xml['log']['logentry']['paths']['path'];
149 BSXml
::UnifyNode($this->files
);
152 // ###################################################################
154 * Gets the desired XML revision information from the repository
156 * @param integer Desired revision
158 private function _fetchRevision($desired)
160 $xml = BSXml
::Parse(BSRegister
::Get('lib')->run('info --xml ' . ($desired > 0 ? '-r' . intval($desired) . ' ' : '') . BSRegister
::Get('lib')->arg($this->path
. $this->subpath
) . ($desired > 0 ? '@' . intval($desired) : ''), true));
161 $this->revision
= intval($xml['info']['entry']['commit']['revision']);
165 /*=====================================================================*\
166 || ###################################################################
169 || ###################################################################
170 \*=====================================================================*/