}
$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) {
$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;
/* 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;
}
}
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
*/
$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
$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'] : '',
}
/**
- * 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)
{
/**
* 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.
/**
* 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.
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])) {
<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>
* 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
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);
}
}
/**
- * 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())
{
$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];
*/
public function isValidRevision($rev)
{
- return true;
+ $rev_ob = $this->getRevisionObject();
+ return $rev_ob->valid($rev);
}
/**
* @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.
*
*/
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);
}
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);
}
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;
}
/**
- * @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
}
/**
- * @package Horde_VC
+ * @package Horde_Vcs
*/
-class Horde_VC_Diff
+class Horde_Vcs_Diff
{
/**
* The available diff types.
* 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
*/
/**
* 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.
*
}
/**
- * @package Horde_VC
+ * @package Horde_Vcs
*/
-abstract class Horde_VC_Directory
+abstract class Horde_Vcs_Directory
{
protected $_rep;
protected $_dirName;
* 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();
}
* @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);
$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)) {
/**
* 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;
}
}
/**
- * @package Horde_VC
+ * @package Horde_Vcs
*/
-class Horde_VC_File
+class Horde_Vcs_File
{
public $rep;
public $dir;
}
/**
- * 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()
{
}
/**
- * 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';
}
/**
- * 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)
{
}
/**
- * 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.
require_once dirname(__FILE__) . '/rcs.php';
/**
- * Horde_VC_cvs implementation.
+ * Horde_Vcs_cvs implementation.
*
* Copyright 2000-2008 The Horde Project (http://www.horde.org/)
*
* 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.
*/
public function getAnnotateObject($filename)
{
- return new Horde_VC_Annotate_cvs($this, $filename);
+ return new Horde_Vcs_Annotate_cvs($this, $filename);
}
/**
{
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.
}
/**
- * 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
}
/**
- * 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').
}
/**
- * 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 = '')
{
/* 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);
}
/**
- * 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
$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;
$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));
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;
}
/**
- * 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';
* 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);
}
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);
}
/**
*
* @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')) {
}
-class Horde_VC_Revision_cvs extends Horde_VC_Revision_rcs {}
+class Horde_Vcs_Revision_cvs extends Horde_Vcs_Revision_rcs {}
<?php
-class Horde_VC_Exception extends Exception {}
+class Horde_Vcs_Exception extends Exception {}
<?php
/**
- * Horde_VC_git implementation.
+ * Horde_Vcs_git implementation.
*
* Copyright 2008 The Horde Project (http://www.horde.org/)
*
*
* @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.
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;
}
/**
- * 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);
}
}
/**
- * 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
}
/**
- * 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.
/**
* 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').
/**
* 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.
*
$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();
}
/**
- * 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
}
/**
- * 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
$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;
}
}
/**
- * 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)
{
$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));
*/
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();
}
}
- function setRepository($rep)
+ public function setRepository($rep)
{
$this->rep = $rep;
}
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
*
* @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.
*/
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);
}
-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);
+ }
+}
<?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.
}
-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.
*/
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;
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;
//}
require_once dirname(__FILE__) . '/rcs.php';
/**
- * Horde_VC_svn implementation.
+ * Horde_Vcs_svn implementation.
*
* Copyright 2000-2008 The Horde Project (http://www.horde.org/)
*
* 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.
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
}
/**
- * 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
}
/**
- * 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').
}
/**
- * 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
}
/**
- * 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
$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));
}
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();
}
/**
- * 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);
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.
*/
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;
}
}
-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);
+ }
+}