2 /*=====================================================================*\
3 || ################################################################### ||
4 || # ViewSVN [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
14 * Command line interface with the SVN commands
20 * Interacts with the command line subsystem to
21 * access SVN information
29 * Path to the SVN binary
35 * Constructor: validate SVN path
37 * @param string Path to SVN binary
39 function SVNLib($svnpath)
43 $this->svnpath
= $viewsvn->shell
->cmd($svnpath);
45 $access = $viewsvn->shell
->exec($this->svnpath
. ' --version');
49 $viewsvn->trigger
->error('svn binary could not be found');
52 if (!preg_match('#^svn, version (.*?)\)$#i', trim($access[0])))
54 $viewsvn->trigger
->error('svn binary does not pass test');
59 * Executes the SVN binary
63 * @param string Command
65 * @return array Output
67 function svn($command)
71 return $viewsvn->shell
->exec($this->svnpath
. ' ' . $command . ' 2>&1');
75 * SVN Wrapper: standard command system
79 * @param string SVN command
80 * @param string Repository
82 * @param integer Revision
84 * @return array Lines of output
86 function std($command, $repos, $path, $revision)
90 $revision = $this->rev($revision);
91 $repospath = $viewsvn->repos
->fetch_path($repos);
93 return $this->svn($command . ' -r' . $revision . ' ' . $repospath . $path);
101 * @param string Repository
103 * @param integer Revision
105 * @return array Lines of blame output
107 function blame($repos, $path, $revision)
109 return $this->std('blame', $repos, $path, $revision);
117 * @param string Repository
119 * @param integer Revision
121 * @return array Lines of cat output
123 function cat($repos, $path, $revision)
125 return $this->std('cat', $repos, $path, $revision);
129 * SVN Wrapper: ls (list)
133 * @param string Repository
135 * @param integer Revision
137 * @return array Lines of list output
139 function ls($repos, $path, $revision)
141 return $this->std('list', $repos, $path, $revision);
145 * Generates a clean revision number
149 * @param integer Revision number
151 * @return mixed Cleaned revision or HEAD
153 function rev($revision)
155 if (($revision = intval($revision)) < 1)
163 /*=====================================================================*\
164 || ###################################################################
167 || ###################################################################
168 \*=====================================================================*/