Use assertValidRevision()
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 23 Jan 2009 19:12:12 +0000 (12:12 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 23 Jan 2009 19:32:35 +0000 (12:32 -0700)
framework/Vcs/lib/Horde/Vcs.php
framework/Vcs/lib/Horde/Vcs/Cvs.php
framework/Vcs/lib/Horde/Vcs/Rcs.php
framework/Vcs/lib/Horde/Vcs/Svn.php

index 1fbb81f..8811f1f 100644 (file)
@@ -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.
index ee98b71..c29fec4 100644 (file)
@@ -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;
                         }
                     }
index ddb22a9..ef42e14 100644 (file)
@@ -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;
     }
 
     /**
index 9e57710..0ea28ab 100644 (file)
@@ -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