All these functions are better off in Horde_Vcs.
} catch (Horde_Vcs_Exception $e) {
Chora::fatal($e);
}
-$rev_ob = $VC->getRevisionObject();
/* Retrieve the desired revision from the GET variable. */
$rev = Util::getFormData('rev');
exit;
}
-$ann = $VC->getAnnotateObject($fl);
try {
- $lines = $ann->doAnnotate($rev);
+ $lines = $VC->annotate($fl, $rev);
} catch (Horde_Vcs_Exception $e) {
Chora::fatal($e);
}
Chora::fatal(sprintf(_("$fullname: no such file or directory"), $where), '404 Not Found');
}
-$rev_ob = $VC->getRevisionObject();
-
if ($atdir) {
try {
$dir = $VC->queryDir($where);
/* Retrieve the actual checkout. */
try {
- $checkOut = $VC->getCheckout($file, $r);
+ $checkOut = $VC->checkout($file, $r);
} catch (Horde_Vcs_Exception $e) {
Chora::fatal($e);
}
} catch (Horde_Vcs_Exception $e) {
Chora::fatal($e);
}
-$rev_ob = $VC->getRevisionObject();
/* Initialise the form variables correctly. */
$r1 = Util::getFormData('r1');
}
/* Human-Readable diff. */
-$abbrev_r1 = $rev_ob->abbrev($r1);
-$abbrev_r2 = $rev_ob->abbrev($r2);
+$abbrev_r1 = $VC->abbrev($r1);
+$abbrev_r2 = $VC->abbrev($r2);
$title = sprintf(_("Diff for %s between version %s and %s"),
Text::htmlallspaces($where), $abbrev_r1, $abbrev_r2);
} catch (Horde_Vcs_Exception $e) {
Chora::fatal($e);
}
-$rev_ob = $VC->getRevisionObject();
$colset = array('#ccdeff', '#ecf', '#fec', '#efc', '#cfd', '#dcdba0');
$branch_colors = $colStack = array();
* Calling this function on every revision of the trunk is enough to
* render out the whole tree.
*/
-function _populateGrid($row, $col, $rev_ob)
+function _populateGrid($row, $col)
{
- global $grid, $branches;
+ global $branches, $grid, $VC;
/* Figure out the starting revision this function uses. */
$rev = $grid[$row][$col];
$brrev = $brkeys[$a];
$brcont = $branches[$brrev];
/* Check to see if current point matches a branch point. */
- if (!strcmp($rev, $rev_ob->strip($brrev, 1))) {
+ if (!strcmp($rev, $VC->strip($brrev, 1))) {
/* If it does, figure out how many rows we have to add. */
$numRows = sizeof($brcont);
/* Check rows in columns to the right, until one is
/* For each value just set, check for sub-branches, - but
* in reverse (VERY IMPORTANT!). */
for ($i = $numRows - 1; $i >= 0 ; --$i) {
- _populateGrid(1 + $i + $row, $insCol, $rev_ob);
+ _populateGrid(1 + $i + $row, $insCol);
}
}
}
* populating the grid with branch revisions. */
for ($row = sizeof($trunk) - 1; $row >= 0; $row--) {
$grid[$row][0] = $trunk[$row];
- _populateGrid($row, 0, $rev_ob);
+ _populateGrid($row, 0);
}
/* Sort the grid array into row order, and determine the maximum
/* Otherwise, this cell has content; determine what it is. */
$rev = $row[$i];
- if ($VC->isValidRevision($rev) && ($rev_ob->sizeof($rev) % 2)) {
+ if ($VC->isValidRevision($rev) && ($VC->sizeof($rev) % 2)) {
/* This is a branch point, so put the info out. */
$bg = isset($branch_colors[$rev]) ? $branch_colors[$rev] : '#e9e9e9';
$symname = $fl->branches[$rev];
} elseif (preg_match('|^:|', $rev)) {
/* This is a continuation cell, so render it with the
* branch colour. */
- $bgbr = $rev_ob->strip(preg_replace('|^\:|', '', $rev), 1);
+ $bgbr = $VC->strip(preg_replace('|^\:|', '', $rev), 1);
$bg = isset($branch_colors[$bgbr]) ? $branch_colors[$bgbr] : '#e9e9e9';
require CHORA_TEMPLATES . '/history/blank.inc';
} elseif ($VC->isValidRevision($rev)) {
/* This cell contains a revision, so render it. */
- $bgbr = $rev_ob->strip($rev, 1);
+ $bgbr = $VC->strip($rev, 1);
$bg = isset($branch_colors[$bgbr]) ? $branch_colors[$bgbr] : '#e9e9e9';
$log = $fl->logs[$rev];
$author = Chora::showAuthorName($log->queryAuthor());
<?php echo $author ?>
</td>
<td class="rev">
- <a rev="<?php echo htmlspecialchars($rev) ?>" href="<?php echo Chora::url('co', $where, array('r' => $rev)) ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($rev)) ?></a>
+ <a rev="<?php echo htmlspecialchars($rev) ?>" href="<?php echo Chora::url('co', $where, array('r' => $rev)) ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($VC->abbrev($rev)) ?></a>
<?php if ($prev): ?>
<a href="<?php echo Chora::url('diff', $where, array('r1' => $prev, 'r2' => $rev)) ?>" title="<?php echo sprintf(_("Diff to %s"), htmlspecialchars($prev)) ?>"><?php echo Horde::img('diff.png') ?></a>
<span class="logdisplay"><?php echo Horde::img('log.png') ?></span>
</td>
<td class="rev">
<?php if ($prev): ?>
- <a rev="<?php echo htmlspecialchars($prev) ?>" href="<?php echo Chora::url('annotate', $where, array('rev' => $prev)) . '#l' . $lineno ?>" title="<?php echo htmlspecialchars($prev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($prev)) ?></a>
+ <a rev="<?php echo htmlspecialchars($prev) ?>" href="<?php echo Chora::url('annotate', $where, array('rev' => $prev)) . '#l' . $lineno ?>" title="<?php echo htmlspecialchars($prev) ?>"><?php echo htmlspecialchars($VC->abbrev($prev)) ?></a>
<?php endif; ?>
</td>
<td class="item<?php echo $style ?>">
<?php endif; ?>
<?php if (!empty($val['tags'])): ?><li class="tags"><?php echo _("Tags:") ?> <?php echo implode(', ', $val['tags']) ?></li><?php endif; ?>
</ul>
- <a href="<?php echo Chora::url('co', $where, array('r' => $val['rev'])) ?>" title="<?php echo htmlspecialchars($val['rev']) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($val['rev'])) ?></a>: <?php echo $val['msg'] ?>
+ <a href="<?php echo Chora::url('co', $where, array('r' => $val['rev'])) ?>" title="<?php echo htmlspecialchars($val['rev']) ?>"><?php echo htmlspecialchars($VC->abbrev($val['rev'])) ?></a>: <?php echo $val['msg'] ?>
<div class="diffclear"></div>
</div>
<?php endforeach; ?>
<?php else: ?>
<a href="<?php echo $url ?>" title="<?php echo htmlspecialchars($head) ?>">
<?php endif; ?>
-<?php echo htmlspecialchars($rev_ob->abbrev($head)) ?></a></strong>
+<?php echo htmlspecialchars($VC->abbrev($head)) ?></a></strong>
</td>
<?php else: ?>
<td>
<?php endif; ?>
<?php echo $name ?>
</td>
- <td><strong><?php echo htmlspecialchars($rev_ob->abbrev($head)) ?></strong></td>
+ <td><strong><?php echo htmlspecialchars($VC->abbrev($head)) ?></strong></td>
<?php endif; ?>
<td><?php echo $author ?></td>
<td sortval="<?php echo (int)$date ?>">
<?php endif ?>
<a href="<?php echo Chora::url('diff', $where, array('r1' => 0, 'r2' => $rev)) ?>" class="sdiff" title="<?php echo _("Show changes to the selected revision") ?>" onclick="Chora_RevLog.sdiff(this);"><?php echo Horde::img('diff.png') ?></a>
</td>
- <td><a href="<?php echo $textUrl ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($rev)) ?></a>
+ <td><a href="<?php echo $textUrl ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($VC->abbrev($rev)) ?></a>
<?php foreach (array_diff($branch_info, array($onb)) as $val): ?>
<span class="branch"><?php echo Horde::link(Chora::url('', $where, array('onb' => $val))) . htmlspecialchars($val) ?></a></span>
<?php endforeach; ?>
* @param array $params A hash containing any additional configuration
* or parameters a subclass might need.
*
- * @return Horde_Vcs The newly created concrete instance, or PEAR_Error on
- * failure.
+ * @return Horde_Vcs The newly created concrete instance.
+ * @throws Horde_Vcs_Exception
*/
static public function factory($driver, $params = array())
{
return new $class($this, $where);
}
- public function getCheckout($file, $rev)
- {
- if (!isset($this->_cache['co'])) {
- $class = 'Horde_Vcs_Checkout_' . $this->_driver;
- $this->_cache['co'] = new $class();
- }
- return $this->_cache['co']->get($this, $file->queryFullPath(), $rev);
- }
-
public function getDiff($file, $rev1, $rev2, $type = 'unified', $num = 3,
$ws = true, $human = false)
{
}
/**
+ * Function which returns a file pointing to the head of the requested
+ * revision of an SVN file.
+ *
+ * @param string $fullname Fully qualified pathname of the desired file
+ * to checkout
+ * @param string $rev Revision number to check out
+ *
+ * @return resource A stream pointer to the head of the checkout.
+ */
+ public function checkout($fullname, $rev)
+ {
+ return null;
+ }
+
+ /**
* $opts:
* 'cache' - (boolean)
* 'quicklog' - (boolean)
return $fileOb;
}
- public function getAnnotateObject($filename)
- {
- $class = 'Horde_Vcs_Annotate_' . $this->_driver;
- return new $class($this, $filename);
- }
-
public function getPatchsetObject($filename, $cache = null)
{
$class = 'Horde_Vcs_Patchset_' . $this->_driver;
return $vc_patchset->getPatchsetObject();
}
- public function getRevisionObject()
+ /**
+ * TODO
+ */
+ public function annotate($fileob, $rev)
{
- if (!isset($this->_cache['rev'])) {
- $class = 'Horde_Vcs_Revision_' . $this->_driver;
- $this->_cache['rev'] = new $class();
- }
- return $this->_cache['rev'];
+ return array();
}
-}
-/**
- * Horde_Vcs annotate class.
- *
- * @package Horde_Vcs
- */
-abstract class Horde_Vcs_Annotate
-{
- protected $_file;
- protected $_rep;
+ /**
+ * Given a revision string, 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.
+ *
+ * @param string $val Input revision string.
+ * @param integer $amount Number of portions to strip.
+ *
+ * @return string Stripped revision string.
+ */
+ public function strip($val, $amount = 1)
+ {
+ return $val;
+ }
/**
- * Constructor
+ * The size of a revision number is the number of portions it has.
+ * For example, 1,2.3.4 is of size 4.
*
- * TODO
+ * @param string $val Revision number to determine size of
+ *
+ * @return integer Size of revision number
*/
- public function __construct($rep, $file)
+ public function sizeof($val)
{
- $this->_rep = $rep;
- $this->_file = $file;
+ return 1;
}
/**
- * TODO
+ * Given two revisions, this figures out which one is greater than the
+ * the other.
+ *
+ * @param string $rev1 Revision string.
+ * @param string $rev2 Second revision string.
+ *
+ * @return integer 1 if the first is greater, -1 if the second if greater,
+ * and 0 if they are equal
*/
- abstract public function doAnnotate($rev);
-}
+ public function cmp($rev1, $rev2)
+ {
+ return strcasecmp($rev1, $rev2);
+ }
-/**
- * @package Horde_Vcs
- */
-abstract class Horde_Vcs_Checkout
-{
/**
- * Function which returns a file pointing to the head of the requested
- * revision of an SVN file.
+ * Return the logical revision before this one.
*
- * @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
+ * @param string $rev Revision string to decrement.
*
- * @return resource|object Either a PEAR_Error object, or a stream
- * pointer to the head of the checkout.
+ * @return string|boolean Revision string, or false if none could be
+ * determined.
*/
- abstract function get($rep, $fullname, $rev);
+ public function prev($rev)
+ {
+ return false;
+ }
+
+ /**
+ * Returns an abbreviated form of the revision, for display.
+ *
+ * @param string $rev The revision string.
+ *
+ * @return string The abbreviated string.
+ */
+ public function abbrev($rev)
+ {
+ return $rev;
+ }
+
}
/**
*/
public function getRevisionRange($rep, $file, $r1, $r2)
{
- $rev_ob = $rep->getRevisionObject();
-
- if ($rev_ob->cmp($r1, $r2) == 1) {
- $curr = $rev_ob->prev($r1);
- $stop = $rev_ob->prev($r2);
+ if ($rev->cmp($r1, $r2) == 1) {
+ $curr = $rev->prev($r1);
+ $stop = $rev->prev($r2);
$flip = true;
} else {
$curr = $r2;
do {
$ret_array[] = $curr;
- $curr = $rev_ob->prev($curr);
+ $curr = $rev->prev($curr);
if ($curr == $stop) {
return ($flip) ? array_reverse($ret_array) : $ret_array;
}
- } while ($rev_ob->cmp($curr, $stop) != -1);
+ } while ($rev->cmp($curr, $stop) != -1);
return array();
}
break;
case Horde_Vcs::SORT_REV:
- $this->_revob = $this->_rep->getRevisionObject();
usort($fileList, array($this, 'fileRevSort'));
break;
*/
public function fileRevSort($a, $b)
{
- return $this->_revob->cmp($a->queryHead(), $b->queryHead());
+ return $this->_rep->cmp($a->queryHead(), $b->queryHead());
}
}
public $symrev = array();
public $revsym = array();
public $branches = array();
- public $revob;
/**
* TODO
return $this->revs[0];
}
+ /**
+ * TODO
+ */
public function queryPreviousRevision($rev)
{
- $last = false;
- foreach ($this->revs as $entry) {
- if ($last) {
- return $entry;
- }
- if ($entry == $rev) {
- $last = true;
- }
- }
-
- return false;
+ $key = array_search($rev, $this->revs);
+ return (($key !== false) && isset($this->revs[$key + 1]))
+ ? $this->revs[$key + 1]
+ : false;
}
/**
case Horde_Vcs::SORT_REV:
default:
- $this->revob = $this->rep->getRevisionObject();
$func = 'Revision';
break;
}
*/
public function sortByRevision($a, $b)
{
- return $this->revob->cmp($b->rev, $a->rev);
+ return $this->rep->cmp($b->rev, $a->rev);
}
public function sortByAge($a, $b)
$this->_rep = $rep;
}
}
-
-/**
- * Horde_Vcs revisions class.
- *
- * Copyright Anil Madhavapeddy, <anil@recoil.org>
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_VC
- */
-class Horde_Vcs_Revision
-{
- /**
- * Given a revision string, 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.
- *
- * @param string $val Input revision string.
- * @param integer $amount Number of portions to strip.
- *
- * @return string Stripped revision string.
- */
- public function strip($val, $amount = 1)
- {
- return $val;
- }
-
- /**
- * The size of a revision number is the number of portions it has.
- * For example, 1,2.3.4 is of size 4.
- *
- * @param string $val Revision number to determine size of
- *
- * @return integer Size of revision number
- */
- public function sizeof($val)
- {
- return 1;
- }
-
- /**
- * Given two revisions, this figures out which one is greater than the
- * the other.
- *
- * @param string $rev1 Revision string.
- * @param string $rev2 Second revision string.
- *
- * @return integer 1 if the first is greater, -1 if the second if greater,
- * and 0 if they are equal
- */
- public function cmp($rev1, $rev2)
- {
- return strcasecmp($rev1, $rev2);
- }
-
- /**
- * Return the logical revision before this one.
- *
- * @param string $rev Revision string to decrement.
- *
- * @return string|boolean Revision string, or false if none could be
- * determined.
- */
- public function prev($rev)
- {
- return false;
- }
-
- /**
- * Returns an abbreviated form of the revision, for display.
- *
- * @param string $rev The revision string.
- *
- * @return string The abbreviated string.
- */
- public function abbrev($rev)
- {
- return $rev;
- }
-
-}
/**
* TODO
*/
- public function getAnnotateObject($filename)
- {
- return new Horde_Vcs_Annotate_Cvs($this, $filename);
- }
-
- /**
- * TODO
- */
public function getPatchsetObject($filename, $cache = null)
{
return parent::getPatchsetObject($this->sourceroot() . '/' . $filename, $cache);
}
-}
-
-/**
- * Horde_Vcs_Cvs annotate class.
- *
- * Anil Madhavapeddy, <anil@recoil.org>
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_Annotate_Cvs extends Horde_Vcs_Annotate
-{
- /**
- * Temporary filename.
- *
- * @var string
- */
- protected $_tmpfile;
/**
- * Constructor.
- *
* TODO
*/
- public function __construct($rep, $file)
+ public function annotate($fileob, $rev)
{
- $this->_tmpfile = Util::getTempFile('vc', true, $rep->getTempPath());
- parent::__construct($rep, $file);
- }
-
- /**
- * TODO
- */
- public function doAnnotate($rev)
- {
- if (!$this->_rep->isValidRevision($rev)) {
+ if (!$this->isValidRevision($rev)) {
return false;
}
- $where = $this->_file->queryModulePath();
- $sourceroot = $this->_rep->sourceroot();
+ $tmpfile = Util::getTempFile('vc', true, $this->getTempPath());
+ $where = $fileob->queryModulePath();
- $pipe = popen($this->_rep->getPath('cvs') . ' -n server > ' . $this->_tmpfile, VC_WINDOWS ? 'wb' : 'w');
+ $pipe = popen($this->getPath('cvs') . ' -n server > ' . escapeshellarg($tmpfile), VC_WINDOWS ? 'wb' : 'w');
$out = array(
- "Root $sourceroot",
+ 'Root ' . $this->sourceroot(),
'Valid-responses ok error Valid-requests Checked-in Updated Merged Removed M E',
'UseUnchanged',
'Argument -r',
- "Argument $rev",
- "Argument $where"
+ 'Argument ' . $rev,
+ 'Argument ' . $where
);
$dirs = explode('/', dirname($where));
while (count($dirs)) {
$out[] = 'Directory ' . implode('/', $dirs);
- $out[] = "$sourceroot/" . implode('/', $dirs);
+ $out[] = $this->sourceroot() . '/' . implode('/', $dirs);
array_pop($dirs);
}
$out[] = 'Directory .';
- $out[] = $sourceroot;
+ $out[] = $this->sourceroot();
$out[] = 'annotate';
foreach ($out as $line) {
}
pclose($pipe);
- if (!($fl = fopen($this->_tmpfile, VC_WINDOWS ? 'rb' : 'r'))) {
+ if (!($fl = fopen($tmpfile, VC_WINDOWS ? 'rb' : 'r'))) {
return false;
}
return $lines;
}
-}
-
-/**
- * Horde_Vcs_cvs checkout class.
- *
- * Anil Madhavapeddy, <anil@recoil.org>
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_Vcs
- */
-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.
+ * Returns a file pointing to the head of the requested revision of a
+ * file.
*
- * @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.
+ * @param string $fullname Fully qualified pathname of the desired file
+ * to checkout.
+ * @param string $rev Revision number to check out.
*
* @return resource A stream pointer to the head of the checkout.
*/
- public function get($rep, $fullname, $rev)
+ public function checkout($fullname, $rev)
{
if (!$rep->isValidRevision($rev)) {
throw new Horde_Vcs_Exception('Invalid revision number');
}
- if (!($RCS = popen($rep->getPath('co') . " -p$rev " . escapeshellarg($fullname) . " 2>&1", VC_WINDOWS ? 'rb' : 'r'))) {
+ if (!($RCS = popen($this->getPath('co') . ' ' . escapeshellarg('-p' . $rev) . ' ' . escapeshellarg($fullname) . " 2>&1", VC_WINDOWS ? 'rb' : 'r'))) {
throw new Horde_Vcs_Exception('Couldn\'t perform checkout of the requested file');
}
* and we check that this is the case and error otherwise
*/
$co = fgets($RCS, 1024);
- if (!preg_match('/^([\S ]+),v\s+-->\s+st(andar)?d ?out(put)?\s*$/', $co, $regs) ||
+ if (!preg_match('/^([\S ]+,v)\s+-->\s+st(andar)?d ?out(put)?\s*$/', $co, $regs) ||
($regs[1] != $fullname)) {
throw new Horde_Vcs_Exception('Unexpected output from checkout: ' . $co);
}
}
$accum = $revsym = $symrev = array();
- $rev_ob = $this->rep->getRevisionObject();
$state = 'init';
foreach ($return_array as $line) {
$branch = $log->queryBranch();
if (empty($this->_branch) ||
in_array($this->_branch, $log->queryBranch()) ||
- (($rev_ob->cmp($rev, $this->branches[$this->_branch]) === -1) &&
+ (($this->rep->cmp($rev, $this->branches[$this->_branch]) === -1) &&
(empty($branch) ||
in_array('HEAD', $branch) ||
(strpos($this->branches[$this->_branch], $rev) === 0)))) {
}
/**
- * TODO
- */
- public function queryPreviousRevision($rev)
- {
- $ob = $this->rep->getRevisionObject();
- return $ob->prev($rev);
- }
-
- /**
* Return the HEAD (most recent) revision number for this file.
*
* @return string HEAD revision number
}
$key = array_keys($this->file->branches, $this->rev);
- if (!empty($key)) {
- return $key;
- }
-
- $rev_ob = $this->file->rep->getRevisionObject();
- return array_keys($this->file->branches, $rev_ob->strip($this->rev, 1));
+ return empty($key)
+ ? array_keys($this->file->branches, $this->rep->strip($this->rev, 1))
+ : $key;
}
}
}
}
-
-class Horde_Vcs_Revision_Cvs extends Horde_Vcs_Revision_Rcs {}
return ($data[1] == 'blob');
}
+ /**
+ * TODO
+ */
public function getCommand()
{
return $this->getPath('git') . ' --git-dir=' . escapeshellarg($this->_sourceroot);
}
- public function getCheckout($file, $rev)
- {
- if (!isset($this->_cache['co'])) {
- $this->_cache['co'] = new Horde_Vcs_Checkout_Git();
- }
- return $this->_cache['co']->get($this, $file->queryModulePath(), $rev);
- }
-
-}
-
-/**
- * Horde_Vcs_Git annotate class.
- *
- * Chuck Hagenbuch <chuck@horde.org>
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_Annotate_Git extends Horde_Vcs_Annotate
-{
/**
* TODO
*/
- public function doAnnotate($rev)
+ public function annotate($fileob, $rev)
{
- $this->_rep->assertValidRevision($rev);
+ $this->assertValidRevision($rev);
- $command = $this->_rep->getCommand() . ' blame -p ' . $rev . ' -- ' . escapeshellarg($this->_file->queryModulePath()) . ' 2>&1';
+ $command = $this->getCommand() . ' blame -p ' . escapeshellarg($rev) . ' -- ' . escapeshellarg($fileob->queryModulePath()) . ' 2>&1';
$pipe = popen($command, 'r');
if (!$pipe) {
throw new Horde_Vcs_Exception('Failed to execute git annotate: ' . $command);
return $lines;
}
-}
-
-/**
- * Horde_Vcs_Git checkout class.
- *
- * Chuck Hagenbuch <chuck@horde.org>
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_Checkout_Git extends Horde_Vcs_Checkout
-{
/**
* Function which returns a file pointing to the head of the requested
* revision of a file.
*
- * @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
*
* @return resource A stream pointer to the head of the checkout.
*/
- function get($rep, $file, $rev)
+ public function checkout($file, $rev)
{
- $rep->assertValidRevision($rev);
+ $this->assertValidRevision($rev);
- $file_ob = $rep->getFileObject($file);
+ $file_ob = $this->getFileObject($file);
- if ($pipe = popen($rep->getCommand() . ' cat-file blob ' . $file_ob->getHashForRevision($rev) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r')) {
+ if ($pipe = popen($this->getCommand() . ' cat-file blob ' . $file_ob->getHashForRevision($rev) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r')) {
return $pipe;
}
throw new Horde_Vcs_Exception('Couldn\'t perform checkout of the requested file');
}
+ /**
+ * Returns an abbreviated form of the revision, for display.
+ *
+ * @param string $rev The revision string.
+ *
+ * @return string The abbreviated string.
+ */
+ public function abbrev($rev)
+ {
+ return substr($rev, 0, 7) . '[...]';
+ }
+
}
/**
return $revs;
}
- private function _getRevisionRange($rep, $file, $r1, $r2)
+ protected function _getRevisionRange($rep, $file, $r1, $r2)
{
$cmd = $rep->getCommand() . ' rev-list ' . escapeshellarg($r1) . '..' . escapeshellarg($r2) . ' -- ' . escapeshellarg($file->queryModulePath());
$revs = array();
exec($cmd, $revs);
- return array_map($revs, 'trim');
+ return array_map('trim', $revs);
}
}
}
}
-
-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.
- */
-
- /**
- * Returns an abbreviated form of the revision, for display.
- *
- * @param string $rev The revision string.
- *
- * @return string The abbreviated string.
- */
- public function abbrev($rev)
- {
- return substr($rev, 0, 7) . '[...]';
- }
-
-}
}
}
-}
-
-class Horde_Vcs_Revision_Rcs extends Horde_Vcs_Revision
-{
/**
* 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
*/
public function strip($val, $amount = 1)
{
- //if (!Horde_Vcs_Revision::valid($val)) {
- // return false;
- //}
+ if (!$this->isValidRevision($val)) {
+ return false;
+ }
$pos = 0;
while ($amount-- > 0 && ($pos = strrpos($val, '.')) !== false) {
$val = substr($val, 0, $pos);
}
- return $pos !== false ? $val : false;
+ return ($pos !== false) ? $val : false;
}
/**
*/
public function sizeof($val)
{
- //@TODO This concept is broken beyond CVS
- //if (!Horde_Vcs_Revision::valid($val)) {
- // return false;
- //}
-
- return (substr_count($val, '.') + 1);
+ return $this->isValidRevision($val)
+ ? (substr_count($val, '.') + 1)
+ : false;
}
/**
}
}
}
+
}
return $command;
}
- public function isValidRevision($rev)
- {
- return $rev && is_numeric($rev);
- }
-}
-
-/**
- * Horde_Vcs_Svn annotate class.
- *
- * Anil Madhavapeddy, <anil@recoil.org>
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_Annotate_Svn extends Horde_Vcs_Annotate
-{
/**
* TODO
*/
- public function doAnnotate($rev)
+ public function annotate($fileob, $rev)
{
- if (!$this->_rep->isValidRevision($rev)) {
+ if (!$this->isValidRevision($rev)) {
return false;
}
- $command = $this->_rep->getCommand() . ' annotate -r 1:' . $rev . ' ' . escapeshellarg($this->_file->queryFullPath()) . ' 2>&1';
+ $command = $this->getCommand() . ' annotate -r ' . escapeshellarg('1:' . $rev) . ' ' . escapeshellarg($fileob->queryFullPath()) . ' 2>&1';
$pipe = popen($command, 'r');
if (!$pipe) {
throw new Horde_Vcs_Exception('Failed to execute svn annotate: ' . $command);
return $lines;
}
-}
-
-/**
- * Horde_Vcs_Svn checkout class.
- *
- * Anil Madhavapeddy, <anil@recoil.org>
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_Vcs
- */
-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_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
*
* @return resource A stream pointer to the head of the checkout.
*/
- public function get($rep, $fullname, $rev)
+ public function checkout($fullname, $rev)
{
if (!$rep->isValidRevision($rev)) {
throw new Horde_Vcs_Exception('Invalid revision number');
}
- return ($RCS = popen($rep->getCommand() . ' cat -r ' . $rev . ' ' . escapeshellarg($fullname) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r'))
+ return ($RCS = popen($this->getCommand() . ' cat -r ' . escapeshellarg($rev) . ' ' . escapeshellarg($fullname) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r'))
? $RCS
: throw new Horde_Vcs_Exception('Couldn\'t perform checkout of the requested file');
}
+ /**
+ * TODO
+ */
+ public function isValidRevision($rev)
+ {
+ return $rev && is_numeric($rev);
+ }
+
}
/**