From bf496881894089aa861cecd26c0701c68f39accd Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 23 Jan 2009 12:12:12 -0700 Subject: [PATCH] Use assertValidRevision() --- framework/Vcs/lib/Horde/Vcs.php | 17 ++++++++--------- framework/Vcs/lib/Horde/Vcs/Cvs.php | 9 ++------- framework/Vcs/lib/Horde/Vcs/Rcs.php | 7 +++---- framework/Vcs/lib/Horde/Vcs/Svn.php | 8 ++------ 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/framework/Vcs/lib/Horde/Vcs.php b/framework/Vcs/lib/Horde/Vcs.php index 1fbb81f86..8811f1f5b 100644 --- a/framework/Vcs/lib/Horde/Vcs.php +++ b/framework/Vcs/lib/Horde/Vcs.php @@ -165,19 +165,10 @@ class Horde_Vcs } /** - * TODO - */ - public function isFile($where) - { - return true; - } - - /** * Throw an exception if the revision number isn't valid. * * @param mixed $rev The revision number * - * @return void * @throws Horde_Vcs_Exception */ public function assertValidRevision($rev) @@ -188,6 +179,14 @@ class Horde_Vcs } /** + * TODO + */ + public function isFile($where) + { + return true; + } + + /** * Create a range of revisions between two revision numbers. * * @param Horde_Vcs_File $file The desired file. diff --git a/framework/Vcs/lib/Horde/Vcs/Cvs.php b/framework/Vcs/lib/Horde/Vcs/Cvs.php index ee98b71b8..c29fec473 100644 --- a/framework/Vcs/lib/Horde/Vcs/Cvs.php +++ b/framework/Vcs/lib/Horde/Vcs/Cvs.php @@ -84,9 +84,7 @@ class Horde_Vcs_Cvs extends Horde_Vcs_Rcs */ public function annotate($fileob, $rev) { - if (!$this->isValidRevision($rev)) { - return false; - } + $this->assertValidRevision($rev); $tmpfile = Util::getTempFile('vc', true, $this->getTempPath()); $where = $fileob->queryModulePath(); @@ -167,9 +165,7 @@ class Horde_Vcs_Cvs extends Horde_Vcs_Rcs */ public function checkout($fullname, $rev) { - if (!$rep->isValidRevision($rev)) { - throw new Horde_Vcs_Exception('Invalid revision number'); - } + $rep->assertValidRevision($rev); 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'); @@ -643,7 +639,6 @@ class Horde_Vcs_Log_Cvs extends Horde_Vcs_Log $brs = preg_split('/;\s*/', $br[1]); foreach ($brs as $brpoint) { if ($this->rep->isValidRevision($brpoint)) { - // TODO: Need branchname $this->branches[] = $brpoint; } } diff --git a/framework/Vcs/lib/Horde/Vcs/Rcs.php b/framework/Vcs/lib/Horde/Vcs/Rcs.php index ddb22a948..ef42e142b 100644 --- a/framework/Vcs/lib/Horde/Vcs/Rcs.php +++ b/framework/Vcs/lib/Horde/Vcs/Rcs.php @@ -234,9 +234,8 @@ class Horde_Vcs_Rcs extends Horde_Vcs */ public function strip($val, $amount = 1) { - if (!$this->isValidRevision($val)) { - return false; - } + $this->assertValidRevision($val); + $pos = 0; while ($amount-- > 0 && ($pos = strrpos($val, '.')) !== false) { $val = substr($val, 0, $pos); @@ -256,7 +255,7 @@ class Horde_Vcs_Rcs extends Horde_Vcs { return $this->isValidRevision($val) ? (substr_count($val, '.') + 1) - : false; + : 0; } /** diff --git a/framework/Vcs/lib/Horde/Vcs/Svn.php b/framework/Vcs/lib/Horde/Vcs/Svn.php index 9e57710f7..0ea28ab59 100644 --- a/framework/Vcs/lib/Horde/Vcs/Svn.php +++ b/framework/Vcs/lib/Horde/Vcs/Svn.php @@ -83,9 +83,7 @@ class Horde_Vcs_Svn extends Horde_Vcs */ public function annotate($fileob, $rev) { - if (!$this->isValidRevision($rev)) { - return false; - } + $this->assertValidRevision($rev); $command = $this->getCommand() . ' annotate -r ' . escapeshellarg('1:' . $rev) . ' ' . escapeshellarg($fileob->queryFullPath()) . ' 2>&1'; $pipe = popen($command, 'r'); @@ -125,9 +123,7 @@ class Horde_Vcs_Svn extends Horde_Vcs */ public function checkout($fullname, $rev) { - if (!$rep->isValidRevision($rev)) { - throw new Horde_Vcs_Exception('Invalid revision number'); - } + $rep->assertValidRevision($rev); return ($RCS = popen($this->getCommand() . ' cat -r ' . escapeshellarg($rev) . ' ' . escapeshellarg($fullname) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r')) ? $RCS -- 2.11.0