Commits

Michael Gatto  committed 553421e

* Now conforms to PEAR coding standard.

  • Participants
  • Parent commits b48996d

Comments (0)

Files changed (3)

File Trunk/VersionControl/Hg/Container/Abstract.php

  *
  * PHP version 5
  *
- * @category    VersionControl
- * @package     Hg
- * @subpackage  Container
- * @author      Michael Gatto <mgatto@lisantra.com>
- * @copyright   2011 Lisantra Technologies, LLC
- * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
- * @link        http://pear.php.net/package/VersionControl_Hg
+ * @category   VersionControl
+ * @package    Hg
+ * @subpackage Container
+ * @author     Michael Gatto <mgatto@lisantra.com>
+ * @copyright  2011 Lisantra Technologies, LLC
+ * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
+ * @link       http://pear.php.net/package/VersionControl_Hg
  */
 
 /**
  *
  * PHP version 5
  *
- * @category    VersionControl
- * @package     Hg
- * @subpackage  Container
- * @author      Michael Gatto <mgatto@lisantra.com>
- * @copyright   2011 Lisantra Technologies, LLC
- * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
- * @link        http://pear.php.net/package/VersionControl_Hg
+ * @category   VersionControl
+ * @package    Hg
+ * @subpackage Container
+ * @author     Michael Gatto <mgatto@lisantra.com>
+ * @copyright  2011 Lisantra Technologies, LLC
+ * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
+ * @link       http://pear.php.net/package/VersionControl_Hg
  */
 abstract class VersionControl_Hg_Container_Abstract
 {
     /**
+     * Sets the path to the container
+     *
      * Setting the path is overridden because each container implementation
      * will validate if the path contains a valid container of the same type
      * as itself
      *
-     * @param string $path
+     * @param string $path the path to the container
+     *
+     * @return null
      */
     abstract public function setPath($path = null);
 
      * it to return null when it needs to and lets the programmer check if a
      * repository has been set or not. Exceptions would remove this control.
      *
-     * @return  string | null
-     * @see     $path
+     * @return string | null
+     * @see $path
      */
     public function getPath()
     {
      *
      * @return string
      */
-    public function __toString() {
+    public function __toString()
+    {
         /* necessary because __toString() MUST return a string, but if
          * getPath() is called on a now-permissible null repository path,
          * we will get a PHP error. */
 
         return $path;
     }
-
-
 }

File Trunk/VersionControl/Hg/Container/Repository.php

  *
  * PHP version 5
  *
- * @category    VersionControl
- * @package     Hg
- * @subpackage  Container
- * @author      Michael Gatto <mgatto@lisantra.com>
- * @copyright   2011 Lisantra Technologies, LLC
- * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
- * @link 		http://pear.php.net/package/VersionControl_Hg
+ * @category   VersionControl
+ * @package    Hg
+ * @subpackage Container
+ * @author     Michael Gatto <mgatto@lisantra.com>
+ * @copyright  2011 Lisantra Technologies, LLC
+ * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
+ * @link       http://pear.php.net/package/VersionControl_Hg
  */
 
 /**
  * <code>
  * $hg = new VersionControl_Hg('/path/to/repo');
  * $repository = $hg->getRepository()->getPath();
+ * </code>
  * or
- * $repository = $hg->repository->delete();
- * </code>
+ * <code>$repository = $hg->repository->delete();</code>
  *
  * PHP version 5
  *
- * @category    VersionControl
- * @package     Hg
- * @subpackage  Container
- * @author      Michael Gatto <mgatto@lisantra.com>
- * @copyright   2011 Lisantra Technologies, LLC
- * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
- * @link        http://pear.php.net/package/VersionControl_Hg
+ * @category   VersionControl
+ * @package    Hg
+ * @subpackage Container
+ * @author     Michael Gatto <mgatto@lisantra.com>
+ * @copyright  2011 Lisantra Technologies, LLC
+ * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
+ * @link       http://pear.php.net/package/VersionControl_Hg
  */
 class VersionControl_Hg_Container_Repository
     extends VersionControl_Hg_Container_Abstract
     /**
      * The name of all Mercurial repository roots.
      *
-     * @FIXME: is this still needed to say?
      * Leading backslash is needed since path may not have a trailing slash.
      *
      * @const string
     /*
      * Hold an instance of the class
      */
-    private static $instance;
+    private static $_instance;
 
     /**
      * Path to a local Mercurial repository
 
     /**
      * Repository constructor which currently does nothing.
-     *    *
-     * @param object $hg   is the root object and as a singleton
-     *                     will always be an instance of VersionControl_Hg
-     * @param string $path is the full path to the user defined executable
+     *
+     * @param VersionControl_Hg $hg   is the root object and as a singleton
+     *                                will always be an instance of
+     *                                VersionControl_Hg
+     * @param string            $path is the full path to the user defined
+     *                                executable
      *
      * @return void
      */
-    private function __construct(VersionControl_Hg $hg, $path) {
+    private function __construct(VersionControl_Hg $hg, $path)
+    {
         $this->setPath($path);
         $this->hg = $hg;
     }
      */
     public static function getInstance($hg = null, $path = null)
     {
-        if ( ! isset(self::$instance) ) {
+        if ( ! isset(self::$_instance) ) {
             $singleton_class = __CLASS__;
-            self::$instance = new $singleton_class($hg, $path);
+            self::$_instance = new $singleton_class($hg, $path);
         }
 
-        return self::$instance;
+        return self::$_instance;
     }
 
     /**
      *
      * @return null
      */
-    public static function reset() {
-        self::$instance = NULL;
+    public static function reset()
+    {
+        self::$_instance = null;
     }
 
     /**
      * repository
      *
      * @param string $path The path to the hg executable
+     *
      * @see self::$path
      *
      * @return VersionControl_Hg
     /**
      * Checks if $this is in fact a valid
      *
-     * @param  string $repo The full repository path.
+     * @param string $path The full repository path.
      *
      * @return boolean
      */
     }
 
     /**
+     * Create a repository
      *
+     * This would make sense in only a very few isntances. For example, if a
+     * programmer instantiated $hg without a path, and did this:
+     * <code>
+     * $hg = new VersionControl_Hg();
+     * $repository = $hg->repository()->create('/path/to/repo');
+     * </code>
      *
-     * @return
+     * However, its probably better to directly use the Init command, since
+     * this create() function merely proxies it.
+     *
+     * @param string $path The path at which to create a new Mercurial
+     *                     repository.
+     *
+     * @return VersionControl_Hg_Container_Repository
      */
     public function create($path)
     {
-        //@TODO FINISH THIS!
-        //must call is_repository on the path first, since setPath was not used in instantiation...?
+        $command = new VersionControl_Hg_Command_Init($path);
+        $repository = $command->run('verbose');
 
-
-        $this->_command = new VersionControl_Hg_Command_Init();
-        //$this->_command = new Hg_Repository_Command_Init($this);
-            //pass $this as dependency injection instead of having
-            //Hg_Repository_Command inherit from Hg_Repository?
-
-
-        //return it so we can chain it
-        return $this->_command;
+        /* return it so we can chain it */
+        return $repository;
     }
 
     /**
     public function delete()
     {
         if ( unlink($this->path) ) {
+            self::reset();
+
             return true;
         } else {
-            //return false;
-            throw new VersionControl_Hg_Container_ExceptionException('The repository could not be deleted.');
+            //or, return false;
+            throw new VersionControl_Hg_Container_ExceptionException(
+                'The repository could not be deleted.'
+            );
         }
     }
 
     /**
      * Prevent users to clone the instance
+     *
+     * @return Exception
      */
     public function __clone()
     {

File Trunk/VersionControl/Hg/Container/WorkingCopy.php

      *
      * @return VersionControl_Hg to enable method chaining
      */
-    public function setPath($path = null) {}
+    public function setPath($path = null)
+    {
 
+    }
 }