We forgot to add includes/class_libsvn.php which makes all those previous commits...
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 10 Apr 2007 01:38:18 +0000 (01:38 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 10 Apr 2007 01:38:18 +0000 (01:38 +0000)
includes/class_libsvn.php [new file with mode: 0644]

diff --git a/includes/class_libsvn.php b/includes/class_libsvn.php
new file mode 100644 (file)
index 0000000..31cef6f
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+/*=====================================================================*\
+|| ###################################################################
+|| # ViewSVN [#]version[#]
+|| # Copyright ©2002-[#]year[#] Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version [#]gpl[#] of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
+\*=====================================================================*/
+
+/**
+* LibSVN
+*
+* This is the command-line library system for Subversion. It handles all
+* the actual lifting and executing.
+*
+* @author              Blue Static
+* @copyright   Copyright (c)2002 - [#]year[#], Blue Static
+* @version             $Revision$
+* @package             ViewSVN
+*
+*/
+class LibSVN 
+{
+       /**
+       * The path to the SVN binary
+       * @var string
+       */
+       private $path;
+       
+       /**
+       * Constructor
+       */
+       public function __construct($path)
+       {
+               $this->path = $path;
+               
+               $access = $this->run('--version');
+               if (!preg_match('#^svn, version (.*?)\)$#i', trim($access[0])))
+               {
+                       throw new Exception(_('The SVN binary does not appear to be valid (it failed our tests)'));
+               }
+       }
+       
+       // ###################################################################
+       /**
+       * Wrapper for escapeshellarg()
+       *
+       * @param        string  The argument
+       *
+       * @return       string  Cleaned argument
+       */
+       public function arg($argument)
+       {
+               return escapeshellarg($argument);
+       }
+       
+       // ###################################################################
+       /**
+       * Wrapper for escapeshellcmd()
+       *
+       * @param        string  Command
+       *
+       * @return       string  Cleaned command
+       */
+       public function cmd($command)
+       {
+               return escapeshellcmd($command);
+       }
+       
+       // ###################################################################
+       /**
+       * Executes a shell command and returns all the output
+       * as an array
+       *
+       * @param        string  UNIX command
+       * @param        bool    Turn the array of output into a string?
+       *
+       * @return       array   Output
+       */
+       public function run($command, $implode = false)
+       {
+               $start = microtime();
+               
+               exec($this->path . ' ' . $command, $output);
+               
+               BSRegister::Debug("exec(" . BSFunctions::FetchMicrotimeDiff($start) . "): $command");
+               
+               if ($implode)
+               {
+                       return implode("\n", $output);
+               }
+               
+               return $output;
+       }
+}
+
+/*=====================================================================*\
+|| ###################################################################
+|| # $HeadURL$
+|| # $Id$
+|| ###################################################################
+\*=====================================================================*/
+?>
\ No newline at end of file