Split subversion support files as well
authorChuck Hagenbuch <chuck@horde.org>
Sun, 28 Nov 2010 04:02:16 +0000 (23:02 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 28 Nov 2010 04:02:16 +0000 (23:02 -0500)
framework/Vcs/lib/Horde/Vcs/Directory/Svn.php [new file with mode: 0644]
framework/Vcs/lib/Horde/Vcs/File/Svn.php [new file with mode: 0644]
framework/Vcs/lib/Horde/Vcs/Log/Svn.php [new file with mode: 0644]
framework/Vcs/lib/Horde/Vcs/Patchset/Svn.php [new file with mode: 0644]
framework/Vcs/lib/Horde/Vcs/Svn.php
framework/Vcs/package.xml

diff --git a/framework/Vcs/lib/Horde/Vcs/Directory/Svn.php b/framework/Vcs/lib/Horde/Vcs/Directory/Svn.php
new file mode 100644 (file)
index 0000000..a127eb1
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Horde_Vcs_Directory_Svn class.
+ *
+ * @author  Anil Madhavapeddy <anil@recoil.org>
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package Horde_Vcs
+ */
+class Horde_Vcs_Directory_Svn extends Horde_Vcs_Directory
+{
+    /**
+     * Create a Directory object to store information about the files in a
+     * single directory in the repository.
+     *
+     * @param Horde_Vcs $rep  The Repository object this directory is part of.
+     * @param string $dn      Path to the directory.
+     * @param array $opts     TODO
+     */
+    public function __construct($rep, $dn, $opts = array())
+    {
+        parent::__construct($rep, $dn, $opts);
+
+        $cmd = $rep->getCommand() . ' ls ' . escapeshellarg($rep->sourceroot() . $this->queryDir()) . ' 2>&1';
+
+        $dir = popen($cmd, 'r');
+        if (!$dir) {
+            throw new Horde_Vcs_Exception('Failed to execute svn ls: ' . $cmd);
+        }
+
+        /* Create two arrays - one of all the files, and the other of
+         * all the dirs. */
+        $errors = array();
+        while (!feof($dir)) {
+            $line = chop(fgets($dir, 1024));
+            if (!strlen($line)) {
+                continue;
+            }
+
+            if (substr($line, 0, 4) == 'svn:') {
+                $errors[] = $line;
+            } elseif (substr($line, -1) == '/') {
+                $this->_dirs[] = substr($line, 0, -1);
+            } else {
+                $this->_files[] = $rep->getFileObject($this->queryDir() . '/' . $line, array('quicklog' => !empty($opts['quicklog'])));
+            }
+        }
+
+        pclose($dir);
+
+        if (empty($errors)) {
+            return true;
+        }
+
+        throw new Horde_Vcs_Exception(implode("\n", $errors));
+    }
+}
diff --git a/framework/Vcs/lib/Horde/Vcs/File/Svn.php b/framework/Vcs/lib/Horde/Vcs/File/Svn.php
new file mode 100644 (file)
index 0000000..724d403
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Horde_Vcs_File_Svn class.
+ *
+ * @author  Anil Madhavapeddy <anil@recoil.org>
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package Horde_Vcs
+ */
+class Horde_Vcs_File_Svn extends Horde_Vcs_File
+{
+    /**
+     * @var resource
+     */
+    public $logpipe;
+
+    /**
+     * Have we initalized logs and revisions?
+     *
+     * @var boolean
+     */
+    private $_initialized = false;
+
+    protected function _ensureRevisionsInitialized()
+    {
+        if (!$this->_initialized) { $this->_init(); }
+        $this->_initialized = true;
+    }
+
+    protected function _ensureLogsInitialized()
+    {
+        if (!$this->_initialized) { $this->_init(); }
+        $this->_initialized = true;
+    }
+
+    protected function _init()
+    {
+        // This doesn't work; need to find another way to simply
+        // request the most recent revision:
+        //
+        // $flag = $this->_quicklog ? '-r HEAD ' : '';
+
+        $cmd = $this->_rep->getCommand() . ' log -v ' . escapeshellarg($this->queryFullPath()) . ' 2>&1';
+        $pipe = popen($cmd, 'r');
+        if (!$pipe) {
+            throw new Horde_Vcs_Exception('Failed to execute svn log: ' . $cmd);
+        }
+
+        $header = fgets($pipe);
+        if (!strspn($header, '-')) {
+            throw new Horde_Vcs_Exception('Error executing svn log: ' . $header);
+        }
+
+        $this->logpipe = $pipe;
+        while (!feof($pipe)) {
+            try {
+                $log = $this->_rep->getLogObject($this, null);
+                $rev = $log->queryRevision();
+                $this->logs[$rev] = $log;
+                $this->_revs[] = $rev;
+            } catch (Horde_Vcs_Exception $e) {}
+
+            if ($this->_quicklog) {
+                break;
+            }
+        }
+
+        pclose($pipe);
+    }
+
+    /**
+     * Returns name of the current file without the repository
+     * extensions (usually ,v).
+     *
+     * @return string  Filename without repository extension.
+     */
+    public function queryName()
+    {
+        return preg_replace('/,v$/', '', $this->_name);
+    }
+}
diff --git a/framework/Vcs/lib/Horde/Vcs/Log/Svn.php b/framework/Vcs/lib/Horde/Vcs/Log/Svn.php
new file mode 100644 (file)
index 0000000..ae73700
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Horde_Vcs_Log_Svn class.
+ *
+ * @author  Anil Madhavapeddy <anil@recoil.org>
+ * @package Horde_Vcs
+ */
+class Horde_Vcs_Log_Svn extends Horde_Vcs_Log
+{
+    /**
+     * TODO
+     */
+    protected $_files = array();
+
+    /**
+     * Constructor.
+     */
+    protected function _init()
+    {
+        $line = fgets($this->_file->logpipe);
+        if (feof($this->_file->logpipe) || !$line) {
+            throw new Horde_Vcs_Exception('No more data');
+        }
+
+        if (preg_match('/^r([0-9]*) \| (.*?) \| (.*) \(.*\) \| ([0-9]*) lines?$/', $line, $matches)) {
+            $this->_rev = $matches[1];
+            $this->_author = $matches[2];
+            $this->_date = strtotime($matches[3]);
+            $size = $matches[4];
+        } else {
+            throw new Horde_Vcs_Exception('SVN Error');
+        }
+
+        fgets($this->_file->logpipe);
+
+        while (($line = trim(fgets($this->_file->logpipe))) != '') {
+            $this->_files[] = $line;
+        }
+
+        for ($i = 0; $i != $size; ++$i) {
+            $this->_log = $this->_log . chop(fgets($this->_file->logpipe)) . "\n";
+        }
+
+        $this->_log = chop($this->_log);
+        fgets($this->_file->logpipe);
+    }
+
+    /**
+     * TODO
+     */
+    public function queryFiles()
+    {
+        return $this->_files;
+    }
+}
diff --git a/framework/Vcs/lib/Horde/Vcs/Patchset/Svn.php b/framework/Vcs/lib/Horde/Vcs/Patchset/Svn.php
new file mode 100644 (file)
index 0000000..70d29a7
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Horde_Vcs_Svn Patchset class.
+ *
+ * @author  Anil Madhavapeddy <anil@recoil.org>
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package Horde_Vcs
+ */
+class Horde_Vcs_Patchset_Svn extends Horde_Vcs_Patchset
+{
+    /**
+     * Constructor
+     *
+     * @param Horde_Vcs $rep  A Horde_Vcs repository object.
+     * @param string $file    The filename to create patchsets for.
+     */
+    public function __construct($rep, $opts = array())
+    {
+        // TODO: Allow access via 'range'
+        $fileOb = $rep->getFileObject($opts['file']);
+
+        foreach ($fileOb->logs as $rev => $log) {
+            $this->_patchsets[$rev] = array(
+                'author' => $log->queryAuthor(),
+                'branch' => '',
+                'date' => $log->queryDate(),
+                'log' => $log->queryLog(),
+                'members' => array(),
+                'tag' => ''
+            );
+
+            foreach ($log->queryFiles() as $file) {
+                $action = substr($file, 0, 1);
+                $file = preg_replace('/.*?\s(.*?)(\s|$).*/', '\\1', $file);
+                $to = $rev;
+                $status = self::MODIFIED;
+                if ($action == 'A') {
+                    $from = null;
+                    $status = self::ADDED;
+                } elseif ($action == 'D') {
+                    $from = $to;
+                    $to = null;
+                    $status = self::DELETED;
+                } else {
+                    // This technically isn't the previous revision,
+                    // but it works for diffing purposes.
+                    $from = $to - 1;
+                }
+
+                $this->_patchsets[$rev]['members'][] = array('file' => $file,
+                                                             'from' => $from,
+                                                             'to' => $to,
+                                                             'status' => $status);
+            }
+        }
+
+        return true;
+    }
+}
index 338f8d5..f1bf8f2 100644 (file)
@@ -207,259 +207,4 @@ class Horde_Vcs_Svn extends Horde_Vcs
         exec($command, $diff, $retval);
         return $diff;
     }
-
-}
-
-/**
- * Horde_Vcs_Svn directory class.
- *
- * @author  Anil Madhavapeddy <anil@recoil.org>
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_Directory_Svn extends Horde_Vcs_Directory
-{
-    /**
-     * Create a Directory object to store information about the files in a
-     * single directory in the repository.
-     *
-     * @param Horde_Vcs $rep  The Repository object this directory is part of.
-     * @param string $dn      Path to the directory.
-     * @param array $opts     TODO
-     */
-    public function __construct($rep, $dn, $opts = array())
-    {
-        parent::__construct($rep, $dn, $opts);
-
-        $cmd = $rep->getCommand() . ' ls ' . escapeshellarg($rep->sourceroot() . $this->queryDir()) . ' 2>&1';
-
-        $dir = popen($cmd, 'r');
-        if (!$dir) {
-            throw new Horde_Vcs_Exception('Failed to execute svn ls: ' . $cmd);
-        }
-
-        /* Create two arrays - one of all the files, and the other of
-         * all the dirs. */
-        $errors = array();
-        while (!feof($dir)) {
-            $line = chop(fgets($dir, 1024));
-            if (!strlen($line)) {
-                continue;
-            }
-
-            if (substr($line, 0, 4) == 'svn:') {
-                $errors[] = $line;
-            } elseif (substr($line, -1) == '/') {
-                $this->_dirs[] = substr($line, 0, -1);
-            } else {
-                $this->_files[] = $rep->getFileObject($this->queryDir() . '/' . $line, array('quicklog' => !empty($opts['quicklog'])));
-            }
-        }
-
-        pclose($dir);
-
-        if (empty($errors)) {
-            return true;
-        }
-
-        throw new Horde_Vcs_Exception(implode("\n", $errors));
-    }
-
-}
-
-/**
- * Horde_Vcs_Svn file class.
- *
- * @author  Anil Madhavapeddy <anil@recoil.org>
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_File_Svn extends Horde_Vcs_File
-{
-    /**
-     * @var resource
-     */
-    public $logpipe;
-
-    /**
-     * Have we initalized logs and revisions?
-     *
-     * @var boolean
-     */
-    private $_initialized = false;
-
-    protected function _ensureRevisionsInitialized()
-    {
-        if (!$this->_initialized) { $this->_init(); }
-        $this->_initialized = true;
-    }
-
-    protected function _ensureLogsInitialized()
-    {
-        if (!$this->_initialized) { $this->_init(); }
-        $this->_initialized = true;
-    }
-
-    protected function _init()
-    {
-        // This doesn't work; need to find another way to simply
-        // request the most recent revision:
-        //
-        // $flag = $this->_quicklog ? '-r HEAD ' : '';
-
-        $cmd = $this->_rep->getCommand() . ' log -v ' . escapeshellarg($this->queryFullPath()) . ' 2>&1';
-        $pipe = popen($cmd, 'r');
-        if (!$pipe) {
-            throw new Horde_Vcs_Exception('Failed to execute svn log: ' . $cmd);
-        }
-
-        $header = fgets($pipe);
-        if (!strspn($header, '-')) {
-            throw new Horde_Vcs_Exception('Error executing svn log: ' . $header);
-        }
-
-        $this->logpipe = $pipe;
-        while (!feof($pipe)) {
-            try {
-                $log = $this->_rep->getLogObject($this, null);
-                $rev = $log->queryRevision();
-                $this->logs[$rev] = $log;
-                $this->_revs[] = $rev;
-            } catch (Horde_Vcs_Exception $e) {}
-
-            if ($this->_quicklog) {
-                break;
-            }
-        }
-
-        pclose($pipe);
-    }
-
-    /**
-     * Returns name of the current file without the repository
-     * extensions (usually ,v).
-     *
-     * @return string  Filename without repository extension.
-     */
-    public function queryName()
-    {
-        return preg_replace('/,v$/', '', $this->_name);
-    }
-
-}
-
-/**
- * Horde_Vcs_Svn log class.
- *
- * @author  Anil Madhavapeddy <anil@recoil.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_Log_Svn extends Horde_Vcs_Log
-{
-    /**
-     * TODO
-     */
-    protected $_files = array();
-
-    /**
-     * Constructor.
-     */
-    protected function _init()
-    {
-        $line = fgets($this->_file->logpipe);
-        if (feof($this->_file->logpipe) || !$line) {
-            throw new Horde_Vcs_Exception('No more data');
-        }
-
-        if (preg_match('/^r([0-9]*) \| (.*?) \| (.*) \(.*\) \| ([0-9]*) lines?$/', $line, $matches)) {
-            $this->_rev = $matches[1];
-            $this->_author = $matches[2];
-            $this->_date = strtotime($matches[3]);
-            $size = $matches[4];
-        } else {
-            throw new Horde_Vcs_Exception('SVN Error');
-        }
-
-        fgets($this->_file->logpipe);
-
-        while (($line = trim(fgets($this->_file->logpipe))) != '') {
-            $this->_files[] = $line;
-        }
-
-        for ($i = 0; $i != $size; ++$i) {
-            $this->_log = $this->_log . chop(fgets($this->_file->logpipe)) . "\n";
-        }
-
-        $this->_log = chop($this->_log);
-        fgets($this->_file->logpipe);
-    }
-
-    /**
-     * TODO
-     */
-    public function queryFiles()
-    {
-        return $this->_files;
-    }
-
-}
-
-/**
- * Horde_Vcs_Svn Patchset class.
- *
- * @author  Anil Madhavapeddy <anil@recoil.org>
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Vcs
- */
-class Horde_Vcs_Patchset_Svn extends Horde_Vcs_Patchset
-{
-    /**
-     * Constructor
-     *
-     * @param Horde_Vcs $rep  A Horde_Vcs repository object.
-     * @param string $file    The filename to create patchsets for.
-     */
-    public function __construct($rep, $opts = array())
-    {
-        // TODO: Allow access via 'range'
-        $fileOb = $rep->getFileObject($opts['file']);
-
-        foreach ($fileOb->logs as $rev => $log) {
-            $this->_patchsets[$rev] = array(
-                'author' => $log->queryAuthor(),
-                'branch' => '',
-                'date' => $log->queryDate(),
-                'log' => $log->queryLog(),
-                'members' => array(),
-                'tag' => ''
-            );
-
-            foreach ($log->queryFiles() as $file) {
-                $action = substr($file, 0, 1);
-                $file = preg_replace('/.*?\s(.*?)(\s|$).*/', '\\1', $file);
-                $to = $rev;
-                $status = self::MODIFIED;
-                if ($action == 'A') {
-                    $from = null;
-                    $status = self::ADDED;
-                } elseif ($action == 'D') {
-                    $from = $to;
-                    $to = null;
-                    $status = self::DELETED;
-                } else {
-                    // This technically isn't the previous revision,
-                    // but it works for diffing purposes.
-                    $from = $to - 1;
-                }
-
-                $this->_patchsets[$rev]['members'][] = array('file' => $file,
-                                                             'from' => $from,
-                                                             'to' => $to,
-                                                             'status' => $status);
-            }
-        }
-
-        return true;
-    }
-
 }
index b79720b..e1daa07 100644 (file)
       <dir name="Directory">
        <file name="Cvs.php" role="php" />
        <file name="Git.php" role="php" />
+       <file name="Svn.php" role="php" />
       </dir> <!-- //lib/Horde/Vcs/Directory -->
       <dir name="File">
        <file name="Cvs.php" role="php" />
        <file name="Git.php" role="php" />
+       <file name="Svn.php" role="php" />
       </dir> <!-- //lib/Horde/Vcs/File -->
       <dir name="Log">
        <file name="Cvs.php" role="php" />
        <file name="Git.php" role="php" />
+       <file name="Svn.php" role="php" />
       </dir> <!-- //lib/Horde/Vcs/Log -->
       <dir name="Patchset">
        <file name="Cvs.php" role="php" />
        <file name="Git.php" role="php" />
+       <file name="Svn.php" role="php" />
       </dir> <!-- //lib/Horde/Vcs/Patchset -->
       <file name="Cvs.php" role="php" />
       <file name="Directory.php" role="php" />
    <install as="Horde/Vcs/Svn.php" name="lib/Horde/Vcs/Svn.php" />
    <install as="Horde/Vcs/Directory/Cvs.php" name="lib/Horde/Vcs/Directory/Cvs.php" />
    <install as="Horde/Vcs/Directory/Git.php" name="lib/Horde/Vcs/Directory/Git.php" />
+   <install as="Horde/Vcs/Directory/Svn.php" name="lib/Horde/Vcs/Directory/Svn.php" />
    <install as="Horde/Vcs/File/Cvs.php" name="lib/Horde/Vcs/File/Cvs.php" />
    <install as="Horde/Vcs/File/Git.php" name="lib/Horde/Vcs/File/Git.php" />
+   <install as="Horde/Vcs/File/Svn.php" name="lib/Horde/Vcs/File/Svn.php" />
    <install as="Horde/Vcs/Log/Cvs.php" name="lib/Horde/Vcs/Log/Cvs.php" />
    <install as="Horde/Vcs/Log/Git.php" name="lib/Horde/Vcs/Log/Git.php" />
+   <install as="Horde/Vcs/Log/Svn.php" name="lib/Horde/Vcs/Log/Svn.php" />
    <install as="Horde/Vcs/Patchset/Cvs.php" name="lib/Horde/Vcs/Patchset/Cvs.php" />
    <install as="Horde/Vcs/Patchset/Git.php" name="lib/Horde/Vcs/Patchset/Git.php" />
+   <install as="Horde/Vcs/Patchset/Svn.php" name="lib/Horde/Vcs/Patchset/Svn.php" />
   </filelist>
  </phprelease>
  <changelog>