Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bug 19465: username/password isn't handled like described in documentation #5

Merged
merged 4 commits into from

2 participants

@opi99
  • Bug 19465 - Add username/password as default option.
  • Bug 19465 - Add config-dir/config-option to default options.
  • Bug 19465 - Update documentation (as url and path are optional arguments and no default options).
  • Bug 18635 - Add Command changelist
  • Bug 19470 - Convert VersionControl_SVN_Comand_List::parseOutputArray into xml parser

Please close the bugs on pear.php.net as I've no rights for that.
Thanks Alex//

PS: I hope phing is compatible to my changes. :-)
PPS: Will fix Bug 19472 in the next days, afterwards it would be nice to get a 0.5.0 release, so I can release Xinc 2.2 :-)

https://pear.php.net/bugs/bug.php?id=19472

@mrook mrook merged commit 26c051b into pear:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
15 SVN.php
@@ -239,17 +239,16 @@ public static function declareErrorMessages()
* <code>
*
* array(
- * 'url' => 'Subversion repository URL',
* 'username' => 'Subversion repository login',
* 'password' => 'Subversion repository password',
- * 'config_dir' => 'Path to a Subversion configuration directory',
+ * 'config-dir' => 'Path to a Subversion configuration directory',
* // [DEFAULT: null]
- * 'dry_run' => true/false,
- * // [DEFAULT: false]
- * 'encoding' => 'Language encoding to use for commit messages',
+ * 'config-option' => 'Set Subversion user configuration',
* // [DEFAULT: null]
- * 'svn_path' => 'Path to the svn client binary installed as part of Subversion',
+ * 'binaryPath' => 'Path to the svn client binary installed as part of Subversion',
* // [DEFAULT: /usr/local/bin/svn]
+ * 'fetchmode' => Type of returning of run function.
+ * // [DEFAULT: VERSIONCONTROL_SVN_FETCHMODE_ASSOC]
* )
*
* </code>
@@ -260,8 +259,6 @@ public static function declareErrorMessages()
* require_once 'VersionControl/SVN.php';
*
* $options = array(
- * 'url' => 'https://www.example.com/repos',
- * 'path' => 'your_project',
* 'username' => 'your_login',
* 'password' => 'your_password',
* );
@@ -269,7 +266,7 @@ public static function declareErrorMessages()
* // Run a log command
* $svn = VersionControl_SVN::factory('log', $options);
*
- * print_r($svn->run());
+ * print_r($svn->run(array('path_to_your_svn'));
* ?>
* </code>
*
View
50 SVN/Command.php
@@ -87,7 +87,7 @@
/**
* Location of the svn client binary installed as part of Subversion
*
- * @var string $binaryPath
+ * @var string $binaryPath
*/
public $binaryPath = '/usr/local/bin/svn';
@@ -150,11 +150,39 @@
*
* If the specified fetchmode isn't available, raw output will be returned.
*
- * @var int
+ * @var int $fetchmode
*/
public $fetchmode = VERSIONCONTROL_SVN_FETCHMODE_ASSOC;
/**
+ * Default username to use for connections.
+ *
+ * @var string $username
+ */
+ public $username = '';
+
+ /**
+ * Default password to use for connections.
+ *
+ * @var string $password
+ */
+ public $password = '';
+
+ /**
+ * Default config-dir to use for connections.
+ *
+ * @var string $configDir
+ */
+ public $configDir = '';
+
+ /**
+ * Default config-option to use for connections.
+ *
+ * @var string $configOption
+ */
+ public $configOption = '';
+
+ /**
* SVN subcommand to run.
*
* @var string $commandName
@@ -188,6 +216,8 @@
protected $validSwitchesValue = array(
'username',
'password',
+ 'config-dir',
+ 'config-option',
);
/**
@@ -197,8 +227,6 @@
'no-auth-cache',
'non-interactive',
'trust-server-cert',
- 'config-dir',
- 'config-option',
);
/**
@@ -339,6 +367,20 @@ protected function preProcessSwitches()
$this->switches['xml'] = true;
}
$this->switches['non-interactive'] = true;
+
+ $this->fillSwitch('username', $this->username);
+ $this->fillSwitch('password', $this->password);
+ $this->fillSwitch('config-dir', $this->configDir);
+ $this->fillSwitch('config-option', $this->configOption);
+ }
+
+ protected function fillSwitch($switchName, $value)
+ {
+ if (!isset($this->switches[$switchName])
+ && '' !== $value
+ ) {
+ $this->switches[$switchName] = $value;
+ }
}
View
91 SVN/Command/Changelist.php
@@ -0,0 +1,91 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+/**
+ * +----------------------------------------------------------------------+
+ * | This LICENSE is in the BSD license style. |
+ * | http://www.opensource.org/licenses/bsd-license.php |
+ * | |
+ * | Redistribution and use in source and binary forms, with or without |
+ * | modification, are permitted provided that the following conditions |
+ * | are met: |
+ * | |
+ * | * Redistributions of source code must retain the above copyright |
+ * | notice, this list of conditions and the following disclaimer. |
+ * | |
+ * | * Redistributions in binary form must reproduce the above |
+ * | copyright notice, this list of conditions and the following |
+ * | disclaimer in the documentation and/or other materials provided |
+ * | with the distribution. |
+ * | |
+ * | * Neither the name of Clay Loveless nor the names of contributors |
+ * | may be used to endorse or promote products derived from this |
+ * | software without specific prior written permission. |
+ * | |
+ * | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+ * | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+ * | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
+ * | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
+ * | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
+ * | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
+ * | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
+ * | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
+ * | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
+ * | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
+ * | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
+ * | POSSIBILITY OF SUCH DAMAGE. |
+ * +----------------------------------------------------------------------+
+ *
+ * PHP version 5
+ *
+ * @category VersionControl
+ * @package VersionControl_SVN
+ * @author Clay Loveless <clay@killersoft.com>
+ * @author Alexander Opitz <opitz.alexander@gmail.com>
+ * @copyright 2004-2007 Clay Loveless
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/VersionControl_SVN
+ */
+
+require_once 'VersionControl/SVN/Command.php';
+
+/**
+ * Subversion Changelist command manager class
+ *
+ * @category VersionControl
+ * @package VersionControl_SVN
+ * @author Clay Loveless <clay@killersoft.com>
+ * @author Alexander Opitz <opitz.alexander@gmail.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version @version@
+ * @link http://pear.php.net/package/VersionControl_SVN
+ */
+class VersionControl_SVN_Command_Changelist extends VersionControl_SVN_Command
+{
+ /**
+ * Constuctor of command. Adds available switches.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->validSwitchesValue = array_merge(
+ $this->validSwitchesValue,
+ array(
+ 'depth',
+ 'targets',
+ 'cl', 'changelist',
+ )
+ );
+
+ $this->validSwitches = array_merge(
+ $this->validSwitches,
+ array(
+ 'q', 'quiet',
+ 'R', 'recursive',
+ 'remove',
+ )
+ );
+ }
+}
+
+?>
View
96 SVN/Command/List.php
@@ -172,100 +172,6 @@ public function __construct()
)
);
}
-
- /**
- * Helper method for parseOutput that parses output into an associative or numbered array
- *
- * @param array $items Item list from the svn list command (already split into an array
- * by exec)
- * @return array
- * @access public
- */
- function parseOutputArray($items)
- {
- $parsed = array();
-
- // check switches for verbose output
- $verbose = false;
- if ((isset($this->switches['v']) && $this->switches['v'] === true) ||
- (isset($this->switches['verbose']) && $this->switches['verbose'] === true)) {
- $verbose = true;
- }
-
-
- if ($verbose) {
- // Must trim off verbose information PRIOR to natcasesort
- $path_items = array();
- $item_vdata = array();
- foreach ($items as $item) {
- // Regex should work with svn list's "%b %d %H:%M" and "%b %d %Y" date formats
- preg_match("/\s*(\d+) \s?(\S+)\s+(\d+)? (\w{3} +\d{2} +\d{2}:?\d{2}) (.*)/", $item, $matches);
- $path_items[] = $matches[5];
- $item_vdata[] = array(
- 'revision' => $matches[1],
- 'author' => $matches[2],
- 'size' => $matches[3],
- 'date' => $matches[4]
- );
- }
- $items = $path_items;
- }
- natcasesort($items);
-
- if ($this->fetchmode == VERSIONCONTROL_SVN_FETCHMODE_ASSOC) {
- $branch_arrays = array();
- foreach ($items as $key => $path) {
- $dir = dirname($path);
- $branches = explode('/', $path);
- $branch = array();
- $last = end($branches);
- $type = 'F';
- if ($last == '') {
- // Directories have an empty item in the last array slot
- $type = 'D';
- $name = prev($branches);
- }
- foreach ($branches as $leaf) {
- if ($leaf == $last) {
- if ($type == 'D') {
- $branch[$dir] = array('name' => array($name), 'type' => array($type));
- } else {
- $branch[$dir] = array('name' => array($leaf), 'type' => array($type));
- }
- } else {
- $branch[$dir] = array('name' => array($leaf), 'type' => array('D'));
- }
- if ($verbose) {
- $branch[$dir] = array_merge($branch[$dir], $item_vdata[$key]);
- }
- }
- $branch_arrays[] = $branch;
- }
-
- foreach ($branch_arrays as $branch) {
- $parsed = array_merge_recursive($parsed, $branch);
- }
- } else {
- foreach ($items as $key => $path) {
- $item = array();
- if (substr($path, -1) == '/') {
- $item['type'] = 'D';
- $path = substr($path, 0, -1);
- } else {
- $item['type'] = 'F';
- }
- $item['name'] = $path;
- if ($verbose) {
- $item = array_merge($item, $item_vdata[$key]);
- }
- $parsed[] = $item;
- }
- }
-
- return $parsed;
- }
-
}
-// }}
-?>
+?>
View
122 SVN/Parsers/List.php
@@ -0,0 +1,122 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+/**
+ * VersionControl_SVN_Info allows for XML formatted output. XML_Parser is used to
+ * manipulate that output.
+ *
+ * +----------------------------------------------------------------------+
+ * | This LICENSE is in the BSD license style. |
+ * | http://www.opensource.org/licenses/bsd-license.php |
+ * | |
+ * | Redistribution and use in source and binary forms, with or without |
+ * | modification, are permitted provided that the following conditions |
+ * | are met: |
+ * | |
+ * | * Redistributions of source code must retain the above copyright |
+ * | notice, this list of conditions and the following disclaimer. |
+ * | |
+ * | * Redistributions in binary form must reproduce the above |
+ * | copyright notice, this list of conditions and the following |
+ * | disclaimer in the documentation and/or other materials provided |
+ * | with the distribution. |
+ * | |
+ * | * Neither the name of Clay Loveless nor the names of contributors |
+ * | may be used to endorse or promote products derived from this |
+ * | software without specific prior written permission. |
+ * | |
+ * | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+ * | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+ * | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
+ * | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
+ * | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
+ * | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
+ * | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
+ * | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
+ * | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
+ * | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
+ * | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
+ * | POSSIBILITY OF SUCH DAMAGE. |
+ * +----------------------------------------------------------------------+
+ *
+ * PHP version 5
+ *
+ * @category VersionControl
+ * @package VersionControl_SVN
+ * @author Clay Loveless <clay@killersoft.com>
+ * @author Alexander Opitz <opitz.alexander@gmail.com>
+ * @copyright 2004-2007 Clay Loveless
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/VersionControl_SVN
+ */
+
+ require_once 'XML/Parser.php';
+
+/**
+ * Class VersionControl_SVN_Parser_Info - XML Parser for Subversion Info output
+ *
+ * @category VersionControl
+ * @package VersionControl_SVN
+ * @author Clay Loveless <clay@killersoft.com>
+ * @author Alexander Opitz <opitz.alexander@gmail.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version @version@
+ * @link http://pear.php.net/package/VersionControl_SVN
+ */
+class VersionControl_SVN_Parser_List extends XML_Parser
+{
+ var $commit = array();
+ var $entry = array();
+ var $list = array();
+
+ function startHandler($xp, $element, &$attribs)
+ {
+ switch ($element) {
+ case 'COMMIT':
+ $this->commit = array(
+ 'REVISION' => $attribs['REVISION']
+ );
+ break;
+ case 'ENTRY':
+ $this->entry = array(
+ 'KIND' => $attribs['KIND']
+ );
+ break;
+ case 'LIST':
+ $this->list = array();
+ break;
+ case 'NAME':
+ case 'AUTHOR':
+ case 'DATE':
+ case 'ROOT':
+ $this->cdata = '';
+ break;
+ }
+ }
+
+ function cdataHandler($xp, $data)
+ {
+ $this->cdata .= $data;
+ }
+
+ function endHandler($xp, $element)
+ {
+ switch($element) {
+ case 'COMMIT':
+ $this->entry['COMMIT'] = $this->commit;
+ break;
+ case 'ENTRY':
+ $this->list[] = $this->entry;
+ break;
+ case 'LIST':
+ break;
+ case 'AUTHOR':
+ case 'DATE':
+ $this->commit[$element] = $this->cdata;
+ break;
+ case 'NAME':
+ $this->entry[$element] = $this->cdata;
+ break;
+ }
+ }
+}
+?>
Something went wrong with that request. Please try again.