Finish PHP 5 Vcs changes; Horde_VC -> Horde_Vcs
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 22 Dec 2008 06:12:24 +0000 (23:12 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 22 Dec 2008 06:25:17 +0000 (23:25 -0700)
chora/browse.php
chora/config/conf.xml
chora/lib/Chora.php
chora/templates/directory/header.inc
framework/Vcs/lib/Horde/Vcs.php
framework/Vcs/lib/Horde/Vcs/Cvs.php
framework/Vcs/lib/Horde/Vcs/Exception.php
framework/Vcs/lib/Horde/Vcs/Git.php
framework/Vcs/lib/Horde/Vcs/Rcs.php
framework/Vcs/lib/Horde/Vcs/Svn.php

index b106c0c..b097df7 100644 (file)
@@ -43,10 +43,10 @@ if ($atdir) {
     }
 
     $umap = array(
-        'age' => Horde_VC::SORT_AGE,
-        'rev' => Horde_VC::SORT_REV,
-        'name' => Horde_VC::SORT_NAME,
-        'author' => Horde_VC::SORT_AUTHOR
+        'age' => Horde_Vcs::SORT_AGE,
+        'rev' => Horde_Vcs::SORT_REV,
+        'name' => Horde_Vcs::SORT_NAME,
+        'author' => Horde_Vcs::SORT_AUTHOR
     );
 
     foreach (array('age', 'rev', 'name', 'author') as $u) {
@@ -137,11 +137,11 @@ $title = sprintf(_("Revisions for %s"), $where);
 $onb = Util::getFormData('onb', 0);
 if ($VC->isValidRevision($onb)) {
     $onb_len = strlen($onb);
-    $onb_base = Horde_VC_Revision::strip($onb, 1);
+    $onb_base = Horde_Vcs_Revision::strip($onb, 1);
     $onb_parents = array();
     while (substr_count($onb_base, '.')) {
         $onb_parents[$onb_base] = true;
-        $onb_base = Horde_VC_Revision::strip($onb_base, 1);
+        $onb_base = Horde_Vcs_Revision::strip($onb_base, 1);
     }
 } else {
     $onb = null;
@@ -183,7 +183,7 @@ foreach ($fl->logs as $lg) {
             /* If the revision is on one of the parent branches, and
              * is before the branch was made, let it through. */
             if ((!isset($onb_parents[$branchRev]) && substr_count($rev, '.') > 1) ||
-                Horde_VC_Revision::cmp($rev, $onb) > 0) {
+                Horde_Vcs_Revision::cmp($rev, $onb) > 0) {
                 continue;
             }
         }
index dd8a1fb..3ae762b 100644 (file)
    characters of this to show before truncating it, and appending '...' to
    indicate there is more to show.">75</configinteger>
    <configenum name="defaultsort" desc="In the directory view, set a default
-   sort order.">Horde_VC::SORT_NAME
+   sort order.">Horde_Vcs::SORT_NAME
     <values>
-     <value desc="no sort">Horde_VC::SORT_NONE</value>
-     <value desc="sort by age">Horde_VC::SORT_AGE</value>
-     <value desc="sort by filename">Horde_VC::SORT_NAME</value>
-     <value desc="sort by revision number">Horde_VC::SORT_REV</value>
-     <value desc="sort by author name">Horde_VC::SORT_AUTHOR</value>
+     <value desc="no sort">Horde_Vcs::SORT_NONE</value>
+     <value desc="sort by age">Horde_Vcs::SORT_AGE</value>
+     <value desc="sort by filename">Horde_Vcs::SORT_NAME</value>
+     <value desc="sort by revision number">Horde_Vcs::SORT_REV</value>
+     <value desc="sort by author name">Horde_Vcs::SORT_AUTHOR</value>
     </values>
    </configenum>
    <configenum name="urls" desc="Does your web server support
index 02259c7..087a27d 100644 (file)
@@ -80,7 +80,7 @@ class Chora {
          */
         $defaultActs = array('sbt' => constant($conf['options']['defaultsort']),
                              'sa'  => 0,
-                             'ord' => Horde_VC::SORT_ASCENDING,
+                             'ord' => Horde_Vcs::SORT_ASCENDING,
                              'ws'  => 1);
 
         /* Use the last sourceroot used as the default value if the user
@@ -117,7 +117,7 @@ class Chora {
         $sourceroot = $acts['rt'];
 
         $conf['paths']['temp'] = Horde::getTempDir();
-        $GLOBALS['VC'] = Horde_VC::factory($sourcerootopts['type'],
+        $GLOBALS['VC'] = Horde_Vcs::factory($sourcerootopts['type'],
             array('sourceroot' => $sourcerootopts['location'],
                   'paths' => $conf['paths'],
                   'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '',
@@ -238,10 +238,10 @@ class Chora {
     }
 
     /**
-     * Given a return object from a Horde_VC:: call, make sure
+     * Given a return object from a Horde_Vcs:: call, make sure
      * that it's not a PEAR_Error object.
      *
-     * @param mixed $e  Return object from a Horde_VC:: call.
+     * @param mixed $e  Return object from a Horde_Vcs:: call.
      */
     function checkError($e)
     {
@@ -542,7 +542,7 @@ class Chora {
     /**
      * Return a list of tags for a given log entry.
      *
-     * @param Horde_VC_Log $lg  The Horde_VC_Log object.
+     * @param Horde_Vcs_Log $lg  The Horde_Vcs_Log object.
      * @param string $where     The filename.
      *
      * @return array  An array of linked tags.
@@ -564,7 +564,7 @@ class Chora {
     /**
      * Return branch information for a given revision.
      *
-     * @param Horde_VC_File $fl  The Horde_VC_File object.
+     * @param Horde_Vcs_File $fl  The Horde_Vcs_File object.
      * @param string $rev        The filename.
      *
      * @return array  An 2-member array - branch name and branch revision.
@@ -572,7 +572,7 @@ class Chora {
     function getBranch($fl, $rev)
     {
         $branchName = '';
-        $branchRev = Horde_VC_Revision::strip($rev, 1);
+        $branchRev = Horde_Vcs_Revision::strip($rev, 1);
         if (isset($fl->branches[$rev])) {
             $branchName = $fl->branches[$rev];
         } elseif (isset($fl->branches[$branchRev])) {
index 3c87049..07fe867 100644 (file)
@@ -2,16 +2,16 @@
 <table id="browse" cellspacing="0" class="browse sortable striped nowrap">
 <thead>
  <tr>
-  <th id="s<?php echo Horde_VC::SORT_NAME ?>"<?php if ($acts['sbt'] == Horde_VC::SORT_NAME) echo ' class="' . $sortdirclass . '"' ?>>
+  <th id="s<?php echo Horde_Vcs::SORT_NAME ?>"<?php if ($acts['sbt'] == Horde_Vcs::SORT_NAME) echo ' class="' . $sortdirclass . '"' ?>>
    <?php echo Horde::widget($url['name'], _("File"), 'sortlink', '', '', _("_File")) ?>
   </th>
-  <th id="s<?php echo Horde_VC::SORT_REV ?>"<?php if ($acts['sbt'] == Horde_VC::SORT_REV) echo ' class="' . $sortdirclass . '"' ?>>
+  <th id="s<?php echo Horde_Vcs::SORT_REV ?>"<?php if ($acts['sbt'] == Horde_Vcs::SORT_REV) echo ' class="' . $sortdirclass . '"' ?>>
    <?php echo Horde::widget($url['rev'], _("Rev"), 'sortlink', '', '', _("_Rev")) ?>
   </th>
-  <th id="s<?php echo Horde_VC::SORT_AUTHOR ?>"<?php if ($acts['sbt'] == Horde_VC::SORT_AUTHOR) echo ' class="' . $sortdirclass . '"' ?>>
+  <th id="s<?php echo Horde_Vcs::SORT_AUTHOR ?>"<?php if ($acts['sbt'] == Horde_Vcs::SORT_AUTHOR) echo ' class="' . $sortdirclass . '"' ?>>
    <?php echo Horde::widget($url['author'], _("Author"), 'sortlink', '', '', _("_Author")) ?>
   </th>
-  <th id="s<?php echo Horde_VC::SORT_AGE ?>"<?php if ($acts['sbt'] == Horde_VC::SORT_AGE) echo ' class="' . $sortdirclass . '"' ?>>
+  <th id="s<?php echo Horde_Vcs::SORT_AGE ?>"<?php if ($acts['sbt'] == Horde_Vcs::SORT_AGE) echo ' class="' . $sortdirclass . '"' ?>>
    <?php echo Horde::widget($url['age'], _("Date"), 'sortlink', '', '', _("Da_te")) ?>
   </th>
   <th class="nosort"><?php echo _("Last Log") ?></th>
index f6225df..fda05a4 100644 (file)
@@ -14,9 +14,9 @@ define('VC_WINDOWS', !strncasecmp(PHP_OS, 'WIN', 3));
  * See the enclosed file COPYING for license information (LGPL). If you
  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  *
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC
+class Horde_Vcs
 {
     /* Sorting options */
     const SORT_NONE = 0;    // don't sort
@@ -57,19 +57,19 @@ class Horde_VC
     protected $_driver;
 
     /**
-     * Attempts to return a concrete Horde_VC instance based on $driver.
+     * Attempts to return a concrete Horde_Vcs instance based on $driver.
      *
-     * @param mixed $driver  The type of concrete Horde_VC subclass to return.
+     * @param mixed $driver  The type of concrete Horde_Vcs subclass to return.
      *                       The code is dynamically included.
      * @param array $params  A hash containing any additional configuration
      *                       or  parameters a subclass might need.
      *
-     * @return Horde_VC  The newly created concrete instance, or PEAR_Error on
+     * @return Horde_Vcs  The newly created concrete instance, or PEAR_Error on
      *                   failure.
      */
     static public function factory($driver, $params = array())
     {
-        $class = 'Horde_VC_' . $driver;
+        $class = 'Horde_Vcs_' . $driver;
         if (class_exists($class)) {
             return new $class($params);
         }
@@ -78,21 +78,21 @@ class Horde_VC
     }
 
     /**
-     * Attempts to return a reference to a concrete Horde_VC instance based
-     * on $driver. It will only create a new instance if no Horde_VC
+     * Attempts to return a reference to a concrete Horde_Vcs instance based
+     * on $driver. It will only create a new instance if no Horde_Vcs
      * instance with the same parameters currently exists.
      *
      * This should be used if multiple types of file backends (and,
-     * thus, multiple Horde_VC instances) are required.
+     * thus, multiple Horde_Vcs instances) are required.
      *
-     * This method must be invoked as: $var = &Horde_VC::singleton()
+     * This method must be invoked as: $var = &Horde_Vcs::singleton()
      *
-     * @param mixed $driver  The type of concrete Horde_VC subclass to return.
+     * @param mixed $driver  The type of concrete Horde_Vcs subclass to return.
      *                       The code is dynamically included.
      * @param array $params  A hash containing any additional configuration
      *                       or parameters a subclass might need.
      *
-     * @return Horde_VC  The concrete reference, or PEAR_Error on failure.
+     * @return Horde_Vcs  The concrete reference, or PEAR_Error on failure.
      */
     static public function &singleton($driver, $params = array())
     {
@@ -100,7 +100,7 @@ class Horde_VC
 
         $signature = serialize(array($driver, $params));
         if (!isset($instances[$signature])) {
-            $instances[$signature] = &Horde_VC::factory($driver, $params);
+            $instances[$signature] = &Horde_Vcs::factory($driver, $params);
         }
 
         return $instances[$signature];
@@ -135,7 +135,8 @@ class Horde_VC
      */
     public function isValidRevision($rev)
     {
-        return true;
+        $rev_ob = $this->getRevisionObject();
+        return $rev_ob->valid($rev);
     }
 
     /**
@@ -152,19 +153,19 @@ class Horde_VC
      * @param mixed $rev The revision number
      *
      * @return void
-     * @throws Horde_VC_Exception
+     * @throws Horde_Vcs_Exception
      */
     public function assertValidRevision($rev)
     {
         if (!$this->isValidRevision($rev)) {
-            throw new Horde_VC_Exception('Invalid revision number');
+            throw new Horde_Vcs_Exception('Invalid revision number');
         }
     }
 
     /**
      * Create a range of revisions between two revision numbers.
      *
-     * @param Horde_VC_File $file  The desired file.
+     * @param Horde_Vcs_File $file  The desired file.
      * @param string $r1           The initial revision.
      * @param string $r2           The ending revision.
      *
@@ -173,7 +174,7 @@ class Horde_VC
      */
     public function getRevisionRange($file, $r1, $r2)
     {
-        $class = 'Horde_VC_Diff_' . $this->_driver;
+        $class = 'Horde_Vcs_Diff_' . $this->_driver;
         $vc_diff = new $class();
         return $vc_diff->getRevisionRange($this, $file, $r1, $r2);
     }
@@ -239,13 +240,13 @@ class Horde_VC
 
     public function queryDir($where)
     {
-        $class = 'Horde_VC_Directory_' . $this->_driver;
+        $class = 'Horde_Vcs_Directory_' . $this->_driver;
         return new $class($this, $where);
     }
 
     public function getCheckout($file, $rev)
     {
-        $class = 'Horde_VC_Checkout_' . $this->_driver;
+        $class = 'Horde_Vcs_Checkout_' . $this->_driver;
         $vc_co = new $class();
         return $vc_co->get($this, $file->queryFullPath(), $rev);
     }
@@ -253,51 +254,51 @@ class Horde_VC
     public function getDiff($file, $rev1, $rev2, $type = 'unified', $num = 3,
                             $ws = true)
     {
-        $class = 'Horde_VC_Diff_' . $this->_driver;
+        $class = 'Horde_Vcs_Diff_' . $this->_driver;
         $vc_diff = new $class();
         return $vc_diff->get($this, $file, $rev1, $rev2, $type, $num, $ws);
     }
 
     public function availableDiffTypes()
     {
-        $class = 'Horde_VC_Diff_' . $this->_driver;
+        $class = 'Horde_Vcs_Diff_' . $this->_driver;
         $vc_diff = new $class();
         return $vc_diff->availableDiffTypes();
     }
 
     public function getFileObject($filename, $cache = null, $quicklog = false)
     {
-        $class = 'Horde_VC_File_' . $this->_driver;
+        $class = 'Horde_Vcs_File_' . $this->_driver;
         $vc_file = new $class($this, $filename, $cache, $quicklog);
         return $vc_file->getFileObject();
     }
 
     public function getAnnotateObject($filename)
     {
-        $class = 'Horde_VC_Annotate_' . $this->_driver;
+        $class = 'Horde_Vcs_Annotate_' . $this->_driver;
         return new $class($this, $filename);
     }
 
     public function getPatchsetObject($filename, $cache = null)
     {
-        $class = 'Horde_VC_Patchset_' . $this->_driver;
-        $vc_patchset = new $class();
-        return $vc_patchset->getPatchsetObject($this, $filename, $cache);
+        $class = 'Horde_Vcs_Patchset_' . $this->_driver;
+        $vc_patchset = new $class($this, $filename, $cache);
+        return $vc_patchset->getPatchsetObject();
     }
 
     public function getRevisionObject()
     {
-        $class = 'Horde_VC_Revision_' . $this->_driver;
+        $class = 'Horde_Vcs_Revision_' . $this->_driver;
         return new $class();
     }
 }
 
 /**
- * Horde_VC annotate class.
+ * Horde_Vcs annotate class.
  *
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-abstract class Horde_VC_Annotate
+abstract class Horde_Vcs_Annotate
 {
     protected $_file;
     protected $_rep;
@@ -320,15 +321,15 @@ abstract class Horde_VC_Annotate
 }
 
 /**
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-abstract class Horde_VC_Checkout
+abstract class Horde_Vcs_Checkout
 {
     /**
      * Function which returns a file pointing to the head of the requested
      * revision of an SVN file.
      *
-     * @param Horde_VC $rep     A repository object
+     * @param Horde_Vcs $rep     A repository object
      * @param string $fullname  Fully qualified pathname of the desired file
      *                          to checkout
      * @param string $rev       Revision number to check out
@@ -340,9 +341,9 @@ abstract class Horde_VC_Checkout
 }
 
 /**
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Diff
+class Horde_Vcs_Diff
 {
     /**
      * The available diff types.
@@ -356,7 +357,7 @@ class Horde_VC_Diff
      * two revisions.
      *
      * @param array $raw  An array of lines of the raw unified diff,
-     *                    normally obtained through Horde_VC_Diff::get().
+     *                    normally obtained through Horde_Vcs_Diff::get().
      *
      * @return array  @TODO
      */
@@ -466,8 +467,8 @@ class Horde_VC_Diff
     /**
      * Create a range of revisions between two revision numbers.
      *
-     * @param Horde_VC $rep        A repository object.
-     * @param Horde_VC_File $file  The desired file.
+     * @param Horde_Vcs $rep        A repository object.
+     * @param Horde_Vcs_File $file  The desired file.
      * @param string $r1           The initial revision.
      * @param string $r2           The ending revision.
      *
@@ -513,9 +514,9 @@ class Horde_VC_Diff
 }
 
 /**
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-abstract class Horde_VC_Directory
+abstract class Horde_Vcs_Directory
 {
     protected $_rep;
     protected $_dirName;
@@ -530,17 +531,17 @@ abstract class Horde_VC_Directory
      * Create a Directory object to store information about the files in a
      * single directory in the repository
      *
-     * @param Horde_VC $rp            The Repository object this directory
+     * @param Horde_Vcs $rp            The Repository object this directory
      *                                is part of.
      * @param string $dn              Path to the directory.
-     * @param Horde_VC_Directory $pn  The parent Directory object to this one.
+     * @param Horde_Vcs_Directory $pn  The parent Directory object to this one.
      */
     public function __construct($rep, $dn, $pn = '')
     {
         $this->_rep = $rep;
         $this->_parent = $pn;
         $this->_moduleName = $dn;
-        $this->_dirName = "/$dn";
+        $this->_dirName = '/' . $dn;
         $this->_dirs = $this->_files = array();
     }
 
@@ -590,8 +591,8 @@ abstract class Horde_VC_Directory
      * @param integer $dir  Of the form SORT_* where * can be:
      *                      ASCENDING, DESCENDING for the order of the sort.
      */
-    public function applySort($how = Horde_VC::SORT_NONE,
-                              $dir = Horde_VC::SORT_ASCENDING)
+    public function applySort($how = Horde_Vcs::SORT_NONE,
+                              $dir = Horde_Vcs::SORT_ASCENDING)
     {
         // Always sort directories by name.
         natcasesort($this->_dirs);
@@ -606,7 +607,7 @@ abstract class Horde_VC_Directory
             $this->_doFileSort($this->_mergedFiles, $how);
         }
 
-        if ($dir == Horde_VC::SORT_DESCENDING) {
+        if ($dir == Horde_Vcs::SORT_DESCENDING) {
             $this->_dirs = array_reverse($this->_dirs);
             $this->_files = array_reverse($this->_files);
             if (isset($this->_mergedFiles)) {
@@ -618,27 +619,27 @@ abstract class Horde_VC_Directory
     /**
      * TODO
      */
-    protected function _doFileSort(&$fileList, $how = Horde_VC::SORT_NONE)
+    protected function _doFileSort(&$fileList, $how = Horde_Vcs::SORT_NONE)
     {
         switch ($how) {
-        case Horde_VC::SORT_AGE:
+        case Horde_Vcs::SORT_AGE:
             usort($fileList, array($this, 'fileAgeSort'));
             break;
 
-        case Horde_VC::SORT_NAME:
+        case Horde_Vcs::SORT_NAME:
             usort($fileList, array($this, 'fileNameSort'));
             break;
 
-        case Horde_VC::SORT_AUTHOR:
+        case Horde_Vcs::SORT_AUTHOR:
             usort($fileList, array($this, 'fileAuthorSort'));
             break;
 
-        case Horde_VC::SORT_REV:
+        case Horde_Vcs::SORT_REV:
             $this->_revob = $this->_rep->getRevisionObject();
             usort($fileList, array($this, 'fileRevSort'));
             break;
 
-        case Horde_VC::SORT_NONE:
+        case Horde_Vcs::SORT_NONE:
         default:
             break;
         }
@@ -686,9 +687,9 @@ abstract class Horde_VC_Directory
 }
 
 /**
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_File
+class Horde_Vcs_File
 {
     public $rep;
     public $dir;
@@ -769,9 +770,9 @@ class Horde_VC_File
     }
 
    /**
-     * Return the last Horde_VC_Log object in the file.
+     * Return the last Horde_Vcs_Log object in the file.
      *
-     * @return Horde_VC_Log of the last entry in the file
+     * @return Horde_Vcs_Log of the last entry in the file
      */
     public function queryLastLog()
     {
@@ -782,24 +783,24 @@ class Horde_VC_File
     }
 
     /**
-     * Sort the list of Horde_VC_Log objects that this file contains.
+     * Sort the list of Horde_Vcs_Log objects that this file contains.
      *
-     * @param integer $how  Horde_VC::SORT_REV (sort by revision),
-     *                      Horde_VC::SORT_NAME (sort by author name), or
-     *                      Horde_VC::SORT_AGE (sort by commit date).
+     * @param integer $how  Horde_Vcs::SORT_REV (sort by revision),
+     *                      Horde_Vcs::SORT_NAME (sort by author name), or
+     *                      Horde_Vcs::SORT_AGE (sort by commit date).
      */
-    public function applySort($how = Horde_VC::SORT_REV)
+    public function applySort($how = Horde_Vcs::SORT_REV)
     {
         switch ($how) {
-        case Horde_VC::SORT_NAME:
+        case Horde_Vcs::SORT_NAME:
             $func = 'Name';
             break;
 
-        case Horde_VC::SORT_AGE:
+        case Horde_Vcs::SORT_AGE:
             $func = 'Age';
             break;
 
-        case Horde_VC::SORT_REV:
+        case Horde_Vcs::SORT_REV:
         default:
             $this->revob = $this->rep->getRevisionObject();
             $func = 'Revision';
@@ -851,14 +852,140 @@ class Horde_VC_File
 }
 
 /**
- * Horde_VC patchset class.
+ * Horde_Vcs log class.
  *
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Patchset
+class Horde_Vcs_Log
+{
+    public $rep;
+    public $file;
+    public $tags;
+    public $rev;
+    public $date;
+    public $log;
+    public $author;
+    public $state;
+    public $lines;
+    public $branches = array();
+
+    /**
+     * Constructor.
+     */
+    public function __construct($rep, $fl)
+    {
+        $this->rep = $rep;
+        $this->file = $fl;
+    }
+
+    public function queryDate()
+    {
+        return $this->date;
+    }
+
+    public function queryRevision()
+    {
+        return $this->rev;
+    }
+
+    public function queryAuthor()
+    {
+        return $this->author;
+    }
+
+    public function queryLog()
+    {
+        return $this->log;
+    }
+
+    public function queryChangedLines()
+    {
+        return isset($this->lines) ? $this->lines : '';
+    }
+
+    /**
+     * Given a branch revision number, this function remaps it
+     * accordingly, and performs a lookup on the file object to
+     * return the symbolic name(s) of that branch in the tree.
+     *
+     * @return hash of symbolic names => branch numbers
+     */
+    public function querySymbolicBranches()
+    {
+        $symBranches = array();
+
+        foreach ($this->branches as $branch) {
+            $parts = explode('.', $branch);
+            $last = array_pop($parts);
+            $parts[] = '0';
+            $parts[] = $last;
+            $rev = implode('.', $parts);
+            if (isset($this->file->branches[$branch])) {
+                $symBranches[$this->file->branches[$branch]] = $branch;
+            }
+        }
+
+        return $symBranches;
+    }
+
+}
+
+/**
+ * Horde_Vcs patchset class.
+ *
+ * @package Horde_Vcs
+ */
+abstract class Horde_Vcs_Patchset
 {
     protected $_rep;
     protected $_patchsets = array();
+    protected $_file;
+    protected $_cache;
+    protected $_ctime = 3600;
+
+    /**
+     * Create a patchset object.
+     *
+     * @param string $file  The filename to get patchsets for.
+     */
+    public function __construct($rep, $file, $cache = null)
+    {
+        $this->_rep = $rep;
+        $this->_file = $file;
+        $this->_cache = $cache;
+    }
+
+    public function &getPatchsetObject()
+    {
+        /* The version of the cached data. Increment this whenever the
+         * internal storage format changes, such that we must
+         * invalidate prior cached data. */
+        if ($this->_cache) {
+            $cacheVersion = 1;
+            $cacheId = $this->_rep->sourceroot() . '_n' . $this->_filename . '_f_v' . $cacheVersion;
+        }
+
+        if ($this->_cache &&
+            $this->_cache->exists($cacheId, $this->_ctime)) {
+            $psOb = unserialize($this->_cache->get($cacheId, $this->_ctime));
+            $psOb->setRepository($this->_rep);
+        } else {
+            $class_name = __CLASS__;
+            $psOb = new $class_name($this->_rep, $this->_filename, $this->_cache);
+            $psOb->setRepository($this->_rep);
+            if (is_a(($result = $psOb->getPatchsets()), 'PEAR_Error')) {
+                return $result;
+            }
+
+            if ($this->_cache) {
+                $this->_cache->set($cacheId, serialize($psOb));
+            }
+        }
+
+        return $psOb;
+    }
+
+    abstract public function getPatchsets();
 
     public function setRepository($rep)
     {
@@ -867,16 +994,26 @@ class Horde_VC_Patchset
 }
 
 /**
- * Horde_VC revisions class.
+ * Horde_Vcs revisions class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
  * @package Hored_VC
  */
-abstract class Horde_VC_Revision
+abstract class Horde_Vcs_Revision
 {
     /**
+     * Validation function to ensure that a revision number is of the right
+     * form.
+     *
+     * @param mixed $rev  The purported revision number.
+     *
+     * @return boolean  True if it is a revision number.
+     */
+    abstract public function valid($rev);
+
+    /**
      * Given a revision number, remove a given number of portions from
      * it. For example, if we remove 2 portions of 1.2.3.4, we are
      * left with 1.2.
index 51d790c..576530e 100644 (file)
@@ -3,7 +3,7 @@
 require_once dirname(__FILE__) . '/rcs.php';
 
 /**
- * Horde_VC_cvs implementation.
+ * Horde_Vcs_cvs implementation.
  *
  * Copyright 2000-2008 The Horde Project (http://www.horde.org/)
  *
@@ -11,9 +11,9 @@ require_once dirname(__FILE__) . '/rcs.php';
  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_cvs extends Horde_VC_rcs
+class Horde_Vcs_cvs extends Horde_Vcs_rcs
 {
     /**
      * Constructor.
@@ -68,7 +68,7 @@ class Horde_VC_cvs extends Horde_VC_rcs
      */
     public function getAnnotateObject($filename)
     {
-        return new Horde_VC_Annotate_cvs($this, $filename);
+        return new Horde_Vcs_Annotate_cvs($this, $filename);
     }
 
     /**
@@ -78,30 +78,17 @@ class Horde_VC_cvs extends Horde_VC_rcs
     {
         return parent::getPatchsetObject($this->sourceroot() . '/' . $filename, $cache);
     }
-
-    /**
-     * Validation function to ensure that a revision number is of the right
-     * form.
-     *
-     * @param mixed $rev  The purported revision number.
-     *
-     * @return boolean  True if it is a revision number.
-     */
-    public function isValidRevision($rev)
-    {
-           return $rev && preg_match('/^[\d\.]+$/', $rev);
-    }
 }
 
 /**
- * Horde_VC_cvs annotate class.
+ * Horde_Vcs_cvs annotate class.
  *
  * Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Annotate_cvs extends Horde_VC_Annotate
+class Horde_Vcs_Annotate_cvs extends Horde_Vcs_Annotate
 {
     /**
      * Temporary filename.
@@ -202,20 +189,20 @@ class Horde_VC_Annotate_cvs extends Horde_VC_Annotate
 }
 
 /**
- * Horde_VC_cvs checkout class.
+ * Horde_Vcs_cvs checkout class.
  *
  * Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Checkout_cvs extends Horde_VC_Checkout
+class Horde_Vcs_Checkout_cvs extends Horde_Vcs_Checkout
 {
     /**
      * Static function which returns a file pointing to the head of the
      * requested revision of an RCS file.
      *
-     * @param Horde_VC_cvs $rep  A repository object
+     * @param Horde_Vcs_cvs $rep  A repository object
      * @param string $fullname   Fully qualified pathname of the desired file
      *                           to checkout
      * @param string $rev        Revision number to check out
@@ -264,20 +251,20 @@ class Horde_VC_Checkout_cvs extends Horde_VC_Checkout
 }
 
 /**
- * Horde_VC_cvs diff class.
+ * Horde_Vcs_cvs diff class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Diff_cvs extends Horde_VC_Diff
+class Horde_Vcs_Diff_cvs extends Horde_Vcs_Diff
 {
     /**
      * Obtain the differences between two revisions of a file.
      *
-     * @param Horde_VC $rep        A repository object.
-     * @param Horde_VC_File $file  The desired file.
+     * @param Horde_Vcs $rep        A repository object.
+     * @param Horde_Vcs_File $file  The desired file.
      * @param string $rev1         Original revision number to compare from.
      * @param string $rev2         New revision number to compare against.
      * @param string $type         The type of diff (e.g. 'unified').
@@ -347,22 +334,22 @@ class Horde_VC_Diff_cvs extends Horde_VC_Diff
 }
 
 /**
- * Horde_VC_cvs directory class.
+ * Horde_Vcs_cvs directory class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Directory_cvs extends Horde_VC_Directory
+class Horde_Vcs_Directory_cvs extends Horde_Vcs_Directory
 {
     /**
      * Creates a CVS Directory object to store information
      * about the files in a single directory in the repository.
      *
-     * @param Horde_VC $rep           A repository object
+     * @param Horde_Vcs $rep           A repository object
      * @param string $dn              Path to the directory.
-     * @param Horde_VC_Directory $pn  The parent Directory object to this one.
+     * @param Horde_Vcs_Directory $pn  The parent Directory object to this one.
      */
     public function __construct($rep, $dn, $pn = '')
     {
@@ -419,7 +406,7 @@ class Horde_VC_Directory_cvs extends Horde_VC_Directory
 
         /* If we want to merge the attic, add it in here. */
         if ($showattic) {
-            $atticDir = new Horde_VC_Directory_cvs($this->_rep, $this->_moduleName . '/Attic', $this);
+            $atticDir = new Horde_Vcs_Directory_cvs($this->_rep, $this->_moduleName . '/Attic', $this);
             if (!is_a($atticDir->browseDir($cache, $quicklog), 'PEAR_Error')) {
                 $this->_atticFiles = $atticDir->queryFileList();
                 $this->_mergedFiles = array_merge($this->_files, $this->_atticFiles);
@@ -432,14 +419,14 @@ class Horde_VC_Directory_cvs extends Horde_VC_Directory
 }
 
 /**
- * Horde_VC_cvs file class.
+ * Horde_Vcs_cvs file class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_File_cvs extends Horde_VC_File
+class Horde_Vcs_File_cvs extends Horde_Vcs_File
 {
     /**
      * Create a repository file object, and give it information about
@@ -459,7 +446,7 @@ class Horde_VC_File_cvs extends Horde_VC_File
         $this->logs = $this->revs = $this->branches = array();
     }
 
-    function &getFileObject()
+    public function &getFileObject()
     {
         /* Assume file is in the Attic if it doesn't exist. */
         $filename = $this->filename;
@@ -479,12 +466,12 @@ class Horde_VC_File_cvs extends Horde_VC_File
             $fileOb = unserialize($this->cache->get($cacheId, $ctime));
             $fileOb->setRepository($this->rep);
         } else {
-            $fileOb = new Horde_VC_File_cvs($this->rep, $filename, $this->cache, $this->quicklog);
+            $fileOb = new Horde_Vcs_File_cvs($this->rep, $filename, $this->cache, $this->quicklog);
             $fileOb->setRepository($this->rep);
             if (is_a(($result = $fileOb->getBrowseInfo()), 'PEAR_Error')) {
                 return $result;
             }
-            $fileOb->applySort(Horde_VC::SORT_AGE);
+            $fileOb->applySort(Horde_Vcs::SORT_AGE);
 
             if ($this->cache) {
                 $this->cache->set($cacheId, serialize($fileOb));
@@ -599,9 +586,9 @@ class Horde_VC_File_cvs extends Horde_VC_File
                     strcmp('----------------------------', $line)) {
                     $accum[] = $line;
                 } elseif (count($accum)) {
-                    // spawn a new Horde_VC_log object and add it to the logs
+                    // spawn a new Horde_Vcs_log object and add it to the logs
                     // hash
-                    $log = new Horde_VC_Log_cvs($this);
+                    $log = new Horde_Vcs_Log_cvs($this);
                     $err = $log->processLog($accum);
                     // TODO: error checks - avsm
                     $this->logs[$log->queryRevision()] = $log;
@@ -666,34 +653,14 @@ class Horde_VC_File_cvs extends Horde_VC_File
 }
 
 /**
- * Horde_VC_cvs log class.
+ * Horde_Vcs_cvs log class.
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Log_cvs {
-
-    var $rep;
-    var $file;
-    var $tags;
-    var $rev;
-    var $date;
-    var $log;
-    var $author;
-    var $state;
-    var $lines;
-    var $branches;
-
-    /**
-     *
-     */
-    public function __construct($fl)
-    {
-        $this->file = $fl;
-        $this->branches = array();
-    }
-
-    function processLog($raw)
+class Horde_Vcs_Log_cvs extends Horde_Vcs_Log
+{
+    public function processLog($raw)
     {
         /* Initialise a simple state machine to parse the output of rlog */
         $state = 'init';
@@ -730,10 +697,9 @@ class Horde_VC_Log_cvs {
                      * push valid revisions into the branches array */
                     $brs = preg_split('/;\s*/', $br[1]);
                     foreach ($brs as $brpoint) {
-                        //@TODO
-                        //if (Horde_VC_Revision::valid($brpoint)) {
+                        if ($this->rep->isValidRevision($brpoint)) {
                             $this->branches[] = $brpoint;
-                        //}
+                        }
                     }
                     array_shift($raw);
                 }
@@ -750,106 +716,33 @@ class Horde_VC_Log_cvs {
             array();
     }
 
-    function queryDate()
-    {
-        return $this->date;
-    }
-
-    function queryRevision()
-    {
-        return $this->rev;
-    }
-
-    function queryAuthor()
-    {
-        return $this->author;
-    }
-
-    function queryLog()
-    {
-        return $this->log;
-    }
-
-    function queryChangedLines()
-    {
-        return isset($this->lines) ? ($this->lines) : '';
-    }
-
-    /**
-     * Given a branch revision number, this function remaps it
-     * accordingly, and performs a lookup on the file object to
-     * return the symbolic name(s) of that branch in the tree.
-     *
-     * @return array  Hash of symbolic names => branch numbers
-     */
-    function querySymbolicBranches()
-    {
-        $symBranches = array();
-        foreach ($this->branches as $branch) {
-            $parts = explode('.', $branch);
-            $last = array_pop($parts);
-            $parts[] = '0';
-            $parts[] = $last;
-            $rev = implode('.', $parts);
-            if (isset($this->file->branches[$branch])) {
-                $symBranches[$this->file->branches[$branch]] = $branch;
-            }
-        }
-        return $symBranches;
-    }
-
 }
 
 /**
- * Horde_VC_cvs Patchset class.
+ * Horde_Vcs_cvs Patchset class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Patchset_cvs extends Horde_VC_Patchset {
-
-    var $_dir;
-    var $_name;
+class Horde_Vcs_Patchset_cvs extends Horde_Vcs_Patchset
+{
+    protected $_dir;
+    protected $_name;
 
     /**
      * Create a patchset object.
      *
      * @param string $file  The filename to get patchsets for.
      */
-    public function __construct($file)
+    public function __construct($rep, $file, $cache = null)
     {
         $this->_name = basename($file);
         $this->_dir = dirname($file);
-    }
-
-    function &getPatchsetObject($rep, $filename, $cache = null)
-    {
-        /* The version of the cached data. Increment this whenever the
-         * internal storage format changes, such that we must
-         * invalidate prior cached data. */
-        $cacheVersion = 1;
-        $cacheId = $rep->sourceroot() . '_n' . $filename . '_f_v' . $cacheVersion;
-
-        $ctime = time() - filemtime($filename . ',v');
-        if ($cache &&
-            $cache->exists($cacheId, $ctime)) {
-            $psOb = unserialize($cache->get($cacheId, $ctime));
-            $psOb->setRepository($rep);
-        } else {
-            $psOb = new Horde_VC_Patchset_cvs($filename);
-            $psOb->setRepository($rep);
-            if (is_a(($result = $psOb->getPatchsets()), 'PEAR_Error')) {
-                return $result;
-            }
-
-            if ($cache) {
-                $cache->set($cacheId, serialize($psOb));
-            }
-        }
+        $this->_ctime = time() - filemtime($file . ',v');
 
-        return $psOb;
+        parent::__construct($rep, $file, $cache);
     }
 
     /**
@@ -858,7 +751,7 @@ class Horde_VC_Patchset_cvs extends Horde_VC_Patchset {
      *
      * @return boolean|object  PEAR_Error object on error, or true on success.
      */
-    function getPatchsets()
+    public function getPatchsets()
     {
         /* Check that we are actually in the filesystem. */
         if (!is_file($this->getFullPath() . ',v')) {
@@ -965,4 +858,4 @@ class Horde_VC_Patchset_cvs extends Horde_VC_Patchset {
 
 }
 
-class Horde_VC_Revision_cvs extends Horde_VC_Revision_rcs {}
+class Horde_Vcs_Revision_cvs extends Horde_Vcs_Revision_rcs {}
index 04c2a78..d5be921 100644 (file)
@@ -1,2 +1,2 @@
 <?php
-class Horde_VC_Exception extends Exception {}
+class Horde_Vcs_Exception extends Exception {}
index cc33f5e..afc8a04 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Horde_VC_git implementation.
+ * Horde_Vcs_git implementation.
  *
  * Copyright 2008 The Horde Project (http://www.horde.org/)
  *
@@ -9,9 +9,9 @@
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
  * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_git extends Horde_VC
+class Horde_Vcs_git extends Horde_Vcs
 {
     /**
      * Constructor.
@@ -30,19 +30,6 @@ class Horde_VC_git extends Horde_VC
         parent::__construct();
     }
 
-    /**
-     * Validation function to ensure that a revision number is of the right
-     * form.
-     *
-     * @param mixed $rev  The purported revision number.
-     *
-     * @return boolean  True if it is a revision number.
-     */
-    public function isValidRevision($rev)
-    {
-        return preg_match('/^[a-f0-9]+$/i', $rev);
-    }
-
     public function getCommand()
     {
         return $this->getPath('git') . ' --git-dir=' . $this->_sourceroot;
@@ -51,19 +38,19 @@ class Horde_VC_git extends Horde_VC
 }
 
 /**
- * Horde_VC_git annotate class.
+ * Horde_Vcs_git annotate class.
  *
  * Chuck Hagenbuch <chuck@horde.org>
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Annotate_git extends Horde_VC_Annotate
+class Horde_Vcs_Annotate_git extends Horde_Vcs_Annotate
 {
     public function __construct($rep, $file)
     {
         if (is_a($file, 'PEAR_Error')) {
-            throw new Horde_VC_Exception($file->getMessage());
+            throw new Horde_Vcs_Exception($file->getMessage());
         }
         parent::__construct($rep, $file);
     }
@@ -124,20 +111,20 @@ class Horde_VC_Annotate_git extends Horde_VC_Annotate
 }
 
 /**
- * Horde_VC_git checkout class.
+ * Horde_Vcs_git checkout class.
  *
  * Chuck Hagenbuch <chuck@horde.org>
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Checkout_git extends Horde_VC_Checkout
+class Horde_Vcs_Checkout_git extends Horde_Vcs_Checkout
 {
     /**
      * Function which returns a file pointing to the head of the requested
      * revision of an SVN file.
      *
-     * @param Horde_VC $rep     A repository object
+     * @param Horde_Vcs $rep     A repository object
      * @param string $fullname  Fully qualified pathname of the desired file
      *                          to checkout
      * @param string $rev       Revision number to check out
@@ -157,14 +144,14 @@ class Horde_VC_Checkout_git extends Horde_VC_Checkout
 }
 
 /**
- * Horde_VC_git diff class.
+ * Horde_Vcs_git diff class.
  *
  * Copyright Chuck Hagenbuch <chuck@horde.org>
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Diff_git extends Horde_VC_Diff
+class Horde_Vcs_Diff_git extends Horde_Vcs_Diff
 {
     /**
      * The available diff types.
@@ -176,8 +163,8 @@ class Horde_VC_Diff_git extends Horde_VC_Diff
     /**
      * Obtain the differences between two revisions of a file.
      *
-     * @param Horde_VC $rep        A repository object.
-     * @param Horde_VC_File $file  The desired file.
+     * @param Horde_Vcs $rep        A repository object.
+     * @param Horde_Vcs_File $file  The desired file.
      * @param string $rev1         Original revision number to compare from.
      * @param string $rev2         New revision number to compare against.
      * @param string $type         The type of diff (e.g. 'unified').
@@ -223,8 +210,8 @@ class Horde_VC_Diff_git extends Horde_VC_Diff
     /**
      * Create a range of revisions between two revision numbers.
      *
-     * @param Horde_VC $rep        A repository object.
-     * @param Horde_VC_File $file  The desired file.
+     * @param Horde_Vcs $rep        A repository object.
+     * @param Horde_Vcs_File $file  The desired file.
      * @param string $r1           The initial revision.
      * @param string $r2           The ending revision.
      *
@@ -236,7 +223,7 @@ class Horde_VC_Diff_git extends Horde_VC_Diff
         $cmd = $rep->getCommand() . ' rev-list ' . $r1 . '..' . $r2;
         $pipe = popen($cmd, 'r');
         if (!is_resource($pipe)) {
-            throw new Horde_VC_Exception('Unable to run ' . $cmd . ': ' . error_get_last());
+            throw new Horde_Vcs_Exception('Unable to run ' . $cmd . ': ' . error_get_last());
         }
 
         $revs = array();
@@ -255,14 +242,14 @@ class Horde_VC_Diff_git extends Horde_VC_Diff
 }
 
 /**
- * Horde_VC_git directory class.
+ * Horde_Vcs_git directory class.
  *
  * Copyright Chuck Hagenbuch <chuck@horde.org>
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Directory_git extends Horde_VC_Directory
+class Horde_Vcs_Directory_git extends Horde_Vcs_Directory
 {
     /**
      * Tell the object to open and browse its current directory, and
@@ -315,14 +302,14 @@ class Horde_VC_Directory_git extends Horde_VC_Directory
 }
 
 /**
- * Horde_VC_git file class.
+ * Horde_Vcs_git file class.
  *
  * Copyright Chuck Hagenbuch <chuck@horde.org>
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_File_git extends Horde_VC_File
+class Horde_Vcs_File_git extends Horde_Vcs_File
 {
     /**
      * Create a repository file object, and give it information about
@@ -387,16 +374,16 @@ class Horde_VC_File_git extends Horde_VC_File
         $cmd = $this->rep->getCommand() . ' rev-list HEAD -- ' . $Q . str_replace($Q, '\\' . $Q, $this->fullname) . $Q . ' 2>&1';
         $revisions = shell_exec($cmd);
         if (substr($revisions, 5) == 'fatal') {
-            throw new Horde_VC_Exception($revisions);
+            throw new Horde_Vcs_Exception($revisions);
         }
 
         if (!strlen($revisions)) {
-            throw new Horde_VC_Exception('No revisions found');
+            throw new Horde_Vcs_Exception('No revisions found');
         }
 
         $this->revs = explode("\n", trim($revisions));
         foreach ($this->revs as $rev) {
-            $this->logs[$rev] = Horde_VC_Log_git::factory($this->rep, $this, $rev);
+            $this->logs[$rev] = Horde_Vcs_Log_git::factory($this->rep, $this, $rev);
             if ($this->quicklog) {
                 break;
             }
@@ -406,27 +393,17 @@ class Horde_VC_File_git extends Horde_VC_File
 }
 
 /**
- * Horde_VC_git log class.
+ * Horde_Vcs_git log class.
  *
  * Chuck Hagenbuch <chuck@horde.org>
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Log_git {
-
-    var $rep;
-    var $err;
-    var $file;
-    var $files = array();
-    var $tags;
-    var $rev;
-    var $date;
-    var $log;
-    var $author;
-    var $state;
-    var $lines;
-    var $branches;
+class Horde_Vcs_Log_git {
+
+    public $err;
+    public $files = array();
 
     public static function factory($rep, $file, $rev)
     {
@@ -442,7 +419,7 @@ class Horde_VC_Log_git {
             $logOb = unserialize($rep->cache->get($cacheId, 0));
             $logOb->setRepository($rep);
         } else {
-            $logOb = new Horde_VC_Log_git($rep, $file, $rev);
+            $logOb = new Horde_Vcs_Log_git($rep, $file, $rev);
 
             if ($rep->cache) {
                 $rep->cache->set($cacheId, serialize($logOb));
@@ -457,20 +434,19 @@ class Horde_VC_Log_git {
      */
     public function __construct($rep, $fl, $rev)
     {
-        $this->rep = $rep;
-        $this->file = $fl;
+        parent::__construct($rep, $fl);
+
         $this->rev = $rev;
-        $this->branches = array();
 
         $cmd = $this->rep->getCommand() . ' whatchanged --no-color --pretty=fuller --no-abbrev -n 1 ' . $this->rev;
         $pipe = popen($cmd, 'r');
         if (!is_resource($pipe)) {
-            throw new Horde_VC_Exception('Unable to run ' . $cmd . ': ' . error_get_last());
+            throw new Horde_Vcs_Exception('Unable to run ' . $cmd . ': ' . error_get_last());
         }
 
         $commit = trim(array_pop(explode(' ', fgets($pipe))));
         if ($commit != $rev) {
-            throw new Horde_VC_Exception('Expected ' . $rev . ', got ' . $commit);
+            throw new Horde_Vcs_Exception('Expected ' . $rev . ', got ' . $commit);
         }
 
         $properties = array();
@@ -513,7 +489,7 @@ class Horde_VC_Log_git {
         }
     }
 
-    function setRepository($rep)
+    public function setRepository($rep)
     {
         $this->rep = $rep;
     }
@@ -524,31 +500,6 @@ class Horde_VC_Log_git {
         return $this->files[$path]['dstSha1'];
     }
 
-    function queryDate()
-    {
-        return $this->date;
-    }
-
-    function queryRevision()
-    {
-        return $this->rev;
-    }
-
-    function queryAuthor()
-    {
-        return $this->author;
-    }
-
-    function queryLog()
-    {
-        return $this->log;
-    }
-
-    function queryChangedLines()
-    {
-        return isset($this->lines) ? ($this->lines) : '';
-    }
-
     /**
      * Given a branch revision number, this function remaps it
      * accordingly, and performs a lookup on the file object to
@@ -556,64 +507,23 @@ class Horde_VC_Log_git {
      *
      * @return hash of symbolic names => branch numbers
      */
-    function querySymbolicBranches()
+    public function querySymbolicBranches()
     {
-        $symBranches = array();
-        return $symBranches;
+        return array();
     }
 
 }
 
 /**
- * Horde_VC_git Patchset class.
+ * Horde_Vcs_git Patchset class.
  *
  * Copyright Chuck Hagenbuch <chuck@horde.org>
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Patchset_git extends Horde_VC_Patchset {
-
-    var $_file;
-
-    /**
-     * Create a patchset object.
-     *
-     * @param string $file  The filename to get patchsets for.
-     */
-    public function __construct($file)
-    {
-        $this->_file = $file;
-    }
-
-    function &getPatchsetObject($rep, $filename, $cache = null)
-    {
-        /* The version of the cached data. Increment this whenever the
-         * internal storage format changes, such that we must
-         * invalidate prior cached data. */
-        $cacheVersion = 1;
-        $cacheId = $rep->sourceroot() . '_n' . $filename . '_f_v' . $cacheVersion;
-
-        if ($cache &&
-            // ?
-            $cache->exists($cacheId, 3600)) {
-            $psOb = unserialize($cache->get($cacheId, 3600));
-            $psOb->setRepository($rep);
-        } else {
-            $psOb = new Horde_VC_Patchset_git($filename);
-            $psOb->setRepository($rep);
-            if (is_a(($result = $psOb->getPatchsets()), 'PEAR_Error')) {
-                return $result;
-            }
-
-            if ($cache) {
-                $cache->set($cacheId, serialize($psOb));
-            }
-        }
-
-        return $psOb;
-    }
-
+class Horde_Vcs_Patchset_git extends Horde_Vcs_Patchset
+{
     /**
      * Populate the object with information about the patchsets that
      * this file is involved in.
@@ -622,20 +532,22 @@ class Horde_VC_Patchset_git extends Horde_VC_Patchset {
      */
     function getPatchsets()
     {
-        $fileOb = new Horde_VC_File_git($this->_rep, $this->_file);
+        $fileOb = new Horde_Vcs_File_git($this->_rep, $this->_file);
         if (is_a(($result = $fileOb->getBrowseInfo()), 'PEAR_Error')) {
             return $result;
         }
 
         $this->_patchsets = array();
         foreach ($fileOb->logs as $rev => $log) {
-            $this->_patchsets[$rev] = array();
-            $this->_patchsets[$rev]['date'] = $log->queryDate();
-            $this->_patchsets[$rev]['author'] = $log->queryAuthor();
-            $this->_patchsets[$rev]['branch'] = '';
-            $this->_patchsets[$rev]['tag'] = '';
-            $this->_patchsets[$rev]['log'] = $log->queryLog();
-            $this->_patchsets[$rev]['members'] = array();
+            $this->_patchsets[$rev] = array(
+                'date' => $log->queryDate(),
+                'author' => $log->queryAuthor(),
+                'branch' => '',
+                'tag' => '',
+                'log' => $log->queryLog(),
+                'members' => array()
+            );
+
             foreach ($log->files as $file) {
                 $action = substr($file, 0, 1);
                 $file = preg_replace('/.*?\s(.*?)(\s|$).*/', '\\1', $file);
@@ -662,4 +574,18 @@ class Horde_VC_Patchset_git extends Horde_VC_Patchset {
 
 }
 
-class Horde_VC_Revision_git extends Horde_VC_Revision {}
+class Horde_Vcs_Revision_git extends Horde_Vcs_Revision
+{
+    /**
+     * Validation function to ensure that a revision number is of the right
+     * form.
+     *
+     * @param mixed $rev  The purported revision number.
+     *
+     * @return boolean  True if it is a revision number.
+     */
+    public function valid($rev)
+    {
+        return preg_match('/^[a-f0-9]+$/i', $rev);
+    }
+}
index 0eb1812..d3ec34c 100644 (file)
@@ -1,14 +1,14 @@
 <?php
 /**
- * Horde_VC_rcs implementation.
+ * Horde_Vcs_rcs implementation.
  *
  * Copyright 2004-2007 Jeff Schwentner <jeffrey.schwentner@lmco.com>
  *
  * @author  Jeff Schwentner <jeffrey.schwentner@lmco.com>
  * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_rcs extends Horde_VC
+class Horde_Vcs_rcs extends Horde_Vcs
 {
     /**
      * Checks an RCS file in with a specified change log.
@@ -232,9 +232,22 @@ class Horde_VC_rcs extends Horde_VC
 
 }
 
-class Horde_VC_Revision_rcs extends Horde_VC_Revision
+class Horde_Vcs_Revision_rcs extends Horde_Vcs_Revision
 {
     /**
+     * Validation function to ensure that a revision number is of the right
+     * form.
+     *
+     * @param mixed $rev  The purported revision number.
+     *
+     * @return boolean  True if it is a revision number.
+     */
+    public function valid($rev)
+    {
+        return $rev && preg_match('/^[\d\.]+$/', $rev);
+    }
+
+    /**
      * Given a revision number, remove a given number of portions from
      * it. For example, if we remove 2 portions of 1.2.3.4, we are
      * left with 1.2.
@@ -246,8 +259,7 @@ class Horde_VC_Revision_rcs extends Horde_VC_Revision
      */
     public function strip($val, $amount = 1)
     {
-        //@TODO This concept is broken beyond CVS
-        //if (!Horde_VC_Revision::valid($val)) {
+        //if (!Horde_Vcs_Revision::valid($val)) {
         //    return false;
         //}
         $pos = 0;
@@ -268,7 +280,7 @@ class Horde_VC_Revision_rcs extends Horde_VC_Revision
     public function sizeof($val)
     {
         //@TODO This concept is broken beyond CVS
-        //if (!Horde_VC_Revision::valid($val)) {
+        //if (!Horde_Vcs_Revision::valid($val)) {
         //    return false;
         //}
 
index cf6355c..1615e37 100644 (file)
@@ -3,7 +3,7 @@
 require_once dirname(__FILE__) . '/rcs.php';
 
 /**
- * Horde_VC_svn implementation.
+ * Horde_Vcs_svn implementation.
  *
  * Copyright 2000-2008 The Horde Project (http://www.horde.org/)
  *
@@ -11,9 +11,9 @@ require_once dirname(__FILE__) . '/rcs.php';
  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_svn extends Horde_VC
+class Horde_Vcs_svn extends Horde_Vcs
 {
     /**
      * SVN username.
@@ -76,31 +76,17 @@ class Horde_VC_svn extends Horde_VC
 
         return $command;
     }
-
-    /**
-     * Validation function to ensure that a revision number is of the right
-     * form.
-     *
-     * @param mixed $rev  The purported revision number.
-     *
-     * @return boolean  True if it is a revision number.
-     */
-    public function isValidRevision($rev)
-    {
-        return is_numeric($rev);
-    }
-
 }
 
 /**
- * Horde_VC_svn annotate class.
+ * Horde_Vcs_svn annotate class.
  *
  * Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Annotate_svn extends Horde_VC_Annotate
+class Horde_Vcs_Annotate_svn extends Horde_Vcs_Annotate
 {
     /**
      * TODO
@@ -141,20 +127,20 @@ class Horde_VC_Annotate_svn extends Horde_VC_Annotate
 }
 
 /**
- * Horde_VC_svn checkout class.
+ * Horde_Vcs_svn checkout class.
  *
  * Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Checkout_svn extends Horde_VC_Checkout
+class Horde_Vcs_Checkout_svn extends Horde_Vcs_Checkout
 {
     /**
      * Function which returns a file pointing to the head of the requested
      * revision of a file.
      *
-     * @param Horde_VC $rep     A repository object
+     * @param Horde_Vcs $rep     A repository object
      * @param string $fullname  Fully qualified pathname of the desired file
      *                          to checkout
      * @param string $rev       Revision number to check out
@@ -176,20 +162,20 @@ class Horde_VC_Checkout_svn extends Horde_VC_Checkout
 }
 
 /**
- * Horde_VC_svn diff class.
+ * Horde_Vcs_svn diff class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Diff_svn extends Horde_VC_Diff
+class Horde_Vcs_Diff_svn extends Horde_Vcs_Diff
 {
     /**
      * Obtain the differences between two revisions of a file.
      *
-     * @param Horde_VC $rep        A repository object.
-     * @param Horde_VC_File $file  The desired file.
+     * @param Horde_Vcs $rep        A repository object.
+     * @param Horde_Vcs_File $file  The desired file.
      * @param string $rev1         Original revision number to compare from.
      * @param string $rev2         New revision number to compare against.
      * @param string $type         The type of diff (e.g. 'unified').
@@ -248,14 +234,14 @@ class Horde_VC_Diff_svn extends Horde_VC_Diff
 }
 
 /**
- * Horde_VC_svn directory class.
+ * Horde_Vcs_svn directory class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Directory_svn extends Horde_VC_Directory
+class Horde_Vcs_Directory_svn extends Horde_Vcs_Directory
 {
     /**
      * Tell the object to open and browse its current directory, and
@@ -307,14 +293,14 @@ class Horde_VC_Directory_svn extends Horde_VC_Directory
 }
 
 /**
- * Horde_VC_svn file class.
+ * Horde_Vcs_svn file class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_File_svn extends Horde_VC_File {
+class Horde_Vcs_File_svn extends Horde_Vcs_File {
 
     /**
      * Create a repository file object, and give it information about
@@ -349,12 +335,12 @@ class Horde_VC_File_svn extends Horde_VC_File {
             $fileOb = unserialize($this->cache->get($cacheId, 3600));
             $fileOb->setRepository($rep);
         } else {
-            $fileOb = new Horde_VC_File_svn($rep, $this->filename, $this->cache, $this->quicklog);
+            $fileOb = new Horde_Vcs_File_svn($rep, $this->filename, $this->cache, $this->quicklog);
             $fileOb->setRepository($rep);
             if (is_a(($result = $fileOb->getBrowseInfo()), 'PEAR_Error')) {
                 return $result;
             }
-            $fileOb->applySort(Horde_VC::SORT_AGE);
+            $fileOb->applySort(Horde_Vcs::SORT_AGE);
 
             if ($this->cache) {
                 $this->cache->set($cacheId, serialize($fileOb));
@@ -402,7 +388,7 @@ class Horde_VC_File_svn extends Horde_VC_File {
         }
 
         while (!feof($pipe)) {
-            $log = new Horde_VC_Log_svn($this->rep, $this);
+            $log = new Horde_Vcs_Log_svn($this->rep, $this);
             $err = $log->processLog($pipe);
             if ($err) {
                 $rev = $log->queryRevision();
@@ -422,39 +408,19 @@ class Horde_VC_File_svn extends Horde_VC_File {
 }
 
 /**
- * Horde_VC_svn log class.
+ * Horde_Vcs_svn log class.
  *
  * Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Log_svn {
-
-    var $rep;
-    var $err;
-    var $file;
-    var $files;
-    var $tags;
-    var $rev;
-    var $date;
-    var $log;
-    var $author;
-    var $state;
-    var $lines;
-    var $branches;
-
-    /**
-     * Constructor.
-     */
-    public function __construct($rep, $fl)
-    {
-        $this->rep = $rep;
-        $this->file = $fl;
-        $this->branches = array();
-    }
+class Horde_Vcs_Log_svn extends Horde_Vcs_Log
+{
+    public $err;
+    public $files;
 
-    function processLog($pipe)
+    public function processLog($pipe)
     {
         $line = fgets($pipe);
 
@@ -489,108 +455,18 @@ class Horde_VC_Log_svn {
         return true;
     }
 
-    function queryDate()
-    {
-        return $this->date;
-    }
-
-    function queryRevision()
-    {
-        return $this->rev;
-    }
-
-    function queryAuthor()
-    {
-        return $this->author;
-    }
-
-    function queryLog()
-    {
-        return $this->log;
-    }
-
-    function queryChangedLines()
-    {
-        return isset($this->lines) ? ($this->lines) : '';
-    }
-
-    /**
-     * Given a branch revision number, this function remaps it
-     * accordingly, and performs a lookup on the file object to
-     * return the symbolic name(s) of that branch in the tree.
-     *
-     * @return hash of symbolic names => branch numbers
-     */
-    function querySymbolicBranches()
-    {
-        $symBranches = array();
-        foreach ($this->branches as $branch) {
-            $parts = explode('.', $branch);
-            $last = array_pop($parts);
-            $parts[] = '0';
-            $parts[] = $last;
-            $rev = implode('.', $parts);
-            if (isset($this->file->branches[$branch])) {
-                $symBranches[$this->file->branches[$branch]] = $branch;
-            }
-        }
-        return $symBranches;
-    }
-
 }
 
 /**
- * Horde_VC_svn Patchset class.
+ * Horde_Vcs_svn Patchset class.
  *
  * Copyright Anil Madhavapeddy, <anil@recoil.org>
  *
  * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
+ * @package Horde_Vcs
  */
-class Horde_VC_Patchset_svn extends Horde_VC_Patchset {
-
-    var $_file;
-
-    /**
-     * Create a patchset object.
-     *
-     * @param string $file  The filename to get patchsets for.
-     */
-    public function __construct($file)
-    {
-        $this->_file = $file;
-    }
-
-    function &getPatchsetObject($rep, $filename, $cache = null)
-    {
-        /* The version of the cached data. Increment this whenever the
-         * internal storage format changes, such that we must
-         * invalidate prior cached data. */
-        $cacheVersion = 1;
-        $cacheId = $rep->sourceroot() . '_n' . $filename . '_f_v' . $cacheVersion;
-
-        if ($cache &&
-            // The file is cached for one hour no matter what, because
-            // there is no way to determine with svn the time the file
-            // last changed.
-            $cache->exists($cacheId, 3600)) {
-            $psOb = unserialize($cache->get($cacheId, 3600));
-            $psOb->setRepository($rep);
-        } else {
-            $psOb = new Horde_VC_Patchset_svn($filename);
-            $psOb->setRepository($rep);
-            if (is_a(($result = $psOb->getPatchsets()), 'PEAR_Error')) {
-                return $result;
-            }
-
-            if ($cache) {
-                $cache->set($cacheId, serialize($psOb));
-            }
-        }
-
-        return $psOb;
-    }
-
+class Horde_Vcs_Patchset_svn extends Horde_Vcs_Patchset
+{
     /**
      * Populate the object with information about the patchsets that
      * this file is involved in.
@@ -599,7 +475,7 @@ class Horde_VC_Patchset_svn extends Horde_VC_Patchset {
      */
     function getPatchsets()
     {
-        $fileOb = new Horde_VC_File_svn($this->_rep, $this->_file);
+        $fileOb = new Horde_Vcs_File_svn($this->_rep, $this->_file);
         if (is_a(($result = $fileOb->getBrowseInfo()), 'PEAR_Error')) {
             return $result;
         }
@@ -639,4 +515,18 @@ class Horde_VC_Patchset_svn extends Horde_VC_Patchset {
 
 }
 
-class Horde_VC_Revision_svn extends Horde_VC_Revision_rcs {}
+class Horde_Vcs_Revision_svn extends Horde_Vcs_Revision_rcs
+{
+    /**
+     * Validation function to ensure that a revision number is of the right
+     * form.
+     *
+     * @param mixed $rev  The purported revision number.
+     *
+     * @return boolean  True if it is a revision number.
+     */
+    public function valid($rev)
+    {
+        return is_numeric($rev);
+    }
+}