[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/phing/tasks/ext/svn/ -> SvnBaseTask.php (source)

   1  <?php
   2  /*
   3   *  $Id: SvnBaseTask.php 3076 2006-12-18 08:52:12Z fabien $
   4   *
   5   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   6   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   7   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   8   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   9   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16   *
  17   * This software consists of voluntary contributions made by many individuals
  18   * and is licensed under the LGPL. For more information please see
  19   * <http://phing.info>.
  20   */
  21   
  22  include_once 'phing/Task.php';
  23  
  24  /**
  25   *  Send a message by mail() 
  26   *
  27   *  <mail to="user@example.org" subject="build complete">The build process is a success...</mail> 
  28   * 
  29   *  @author   Francois Harvey at SecuriWeb (http://www.securiweb.net)
  30   *  @version  $Id: SvnBaseTask.php 3076 2006-12-18 08:52:12Z fabien $
  31   *  @package  phing.tasks.ext
  32   */
  33  abstract class SvnBaseTask extends Task
  34  {
  35      private $workingCopy = "";
  36      
  37      private $repositoryUrl = "";
  38      
  39      private $svnPath = "/usr/bin/svn";
  40      
  41      private $svn = NULL;
  42      
  43      private $mode = "";
  44      
  45      private $svnArgs = array();
  46  
  47      /**
  48       * Initialize Task.
  49        * This method includes any necessary SVN libraries and triggers
  50       * appropriate error if they cannot be found.  This is not done in header
  51       * because we may want this class to be loaded w/o triggering an error.
  52       */
  53  	function init() {
  54          include_once 'VersionControl/SVN.php';
  55          if (!class_exists('VersionControl_SVN')) {
  56              throw new Exception("SvnLastRevisionTask depends on PEAR VersionControl_SVN package being installed.");
  57          }
  58      }
  59  
  60      /**
  61       * Sets the path to the workingcopy
  62       */
  63  	function setWorkingCopy($workingCopy)
  64      {
  65          $this->workingCopy = $workingCopy;
  66      }
  67  
  68      /**
  69       * Returns the path to the workingcopy
  70       */
  71  	function getWorkingCopy()
  72      {
  73          return $this->workingCopy;
  74      }
  75  
  76      /**
  77       * Sets the path/URI to the repository
  78       */
  79  	function setRepositoryUrl($repositoryUrl)
  80      {
  81          $this->repositoryUrl = $repositoryUrl;
  82      }
  83  
  84      /**
  85       * Returns the path/URI to the repository
  86       */
  87  	function getRepositoryUrl()
  88      {
  89          return $this->repositoryUrl;
  90      }
  91  
  92      /**
  93       * Sets the path to the SVN executable
  94       */
  95  	function setSvnPath($svnPath)
  96      {
  97          $this->svnPath = $svnPath;
  98      }
  99  
 100      /**
 101       * Returns the path to the SVN executable
 102       */
 103  	function getSvnPath()
 104      {
 105          return $this->svnPath;
 106      }
 107      
 108      /**
 109       * Creates a VersionControl_SVN class based on $mode
 110       *
 111       * @param string The SVN mode to use (info, export, checkout, ...)
 112       * @throws BuildException
 113       */
 114  	protected function setup($mode)
 115      {
 116          $this->mode = $mode;
 117          
 118          // Set up runtime options. Will be passed to all
 119          // subclasses.
 120          $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ASSOC, 'svn_path' => $this->getSvnPath());
 121          
 122          // Pass array of subcommands we need to factory
 123          $this->svn = VersionControl_SVN::factory($mode, $options);
 124  
 125          if (!empty($this->repositoryUrl))
 126          {
 127              $this->svnArgs = array($this->repositoryUrl);
 128          }
 129          else
 130          if (!empty($this->workingCopy))
 131          {
 132              if (is_dir($this->workingCopy))
 133              {
 134                  if (in_array(".svn", scandir($this->workingCopy)))
 135                  {
 136                      $this->svnArgs = array($this->workingCopy);
 137                  }
 138                  else
 139                  {
 140                      throw new BuildException("'".$this->workingCopy."' doesn't seem to be a working copy");
 141                  }
 142              }
 143              else
 144              {
 145                  throw new BuildException("'".$this->workingCopy."' is not a directory");
 146              }
 147          }
 148      }
 149      
 150      /**
 151       * Executes the constructed VersionControl_SVN instance
 152       *
 153       * @param array Additional arguments to pass to SVN.
 154       * @param array Switches to pass to SVN.
 155       * @return string Output generated by SVN.
 156       */
 157  	protected function run($args = array(), $switches = array())
 158      {
 159          $svnstack = PEAR_ErrorStack::singleton('VersionControl_SVN');
 160          
 161          $tempArgs = $this->svnArgs;
 162          
 163          $tempArgs = array_merge($tempArgs, $args);
 164          
 165          if ($output = $this->svn->run($tempArgs, $switches))
 166          {
 167              return $output;
 168          }
 169          else
 170          {
 171              if (count($errs = $svnstack->getErrors()))
 172              {
 173                  $err = current($errs);
 174  
 175                  throw new BuildException("Failed to run the 'svn " . $this->mode . "' command: " . $err['message']);
 176              }
 177          }
 178      }
 179  }
 180  ?>


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7