Fixing the browser (mostly)
[viewsvn.git] / includes / class_revision.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 /**
23 * Revision
24 *
25 * This class represents one revision in a given repository
26 *
27 * @author Blue Static
28 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
29 * @version $Revision$
30 * @package ViewSVN
31 *
32 */
33 class Revision
34 {
35 /**
36 * Repository path
37 * @var string
38 */
39 private $path;
40
41 /**
42 * Repository name
43 * @var string
44 */
45 private $repos;
46
47 /**
48 * The revision number
49 * @var integer
50 */
51 public $revision;
52
53 // ###################################################################
54 /**
55 * Creates a new revision for a given repository and revision
56 *
57 * @param string Repository
58 * @param integer Revision to get; to get HEAD, specify 0
59 */
60 public function __construct($repos, $rev = 0)
61 {
62 $this->path = BSRegister::Get('repos')->fetchPath($repos);
63 $this->repos = $repos;
64
65 $this->_fetchRevision($rev);
66 }
67
68 // ###################################################################
69 /**
70 * Gets the desired XML revision information from the repository
71 *
72 * @param integer Desired revision
73 */
74 private function _fetchRevision($desired)
75 {
76 $xml = BSXml::Parse(BSRegister::Get('lib')->run('info --xml ' . ($desired > 0 ? '-r' . intval($desired) . ' ' : '') . BSRegister::Get('lib')->arg($this->path), true));
77 $this->revision = intval($xml['info']['entry']['commit']['revision']);
78 }
79 }
80
81 /*=====================================================================*\
82 || ###################################################################
83 || # $HeadURL$
84 || # $Id$
85 || ###################################################################
86 \*=====================================================================*/
87 ?>